Score:0

Firefox snap version in 21.10 CORS problem

in flag

After upgrading to 21.10, I run into a CORS problem with an HTML page that uses Javascript fetch() to GET a page from a server. Same page does not have problems with Chromium under 21.10 (or Firefox or Safari on OSX).

Looking at the inspector, the difference seems to be that "Snap Firefox":

  1. has a different value for the REFERER header (it is shortened to http://127.0.0.1:5000/ instead of http://localhost:5000/resource/527706d7e339cac99572cad1b7b789c8 in the working browsers);
  2. there is an ORIGIN header with value http://127.0.0.1:5000, which is absent in the working browsers

Anyone has any ideas why Snap Firefox is doing this and how it can be solved?

UPDATE / ANSWER:

tl/dr; it boils down to the difference between 127.0.0.1 and localhost, but with a twist.

First of all, the CORS error only occurs when 127.0.0.1 and not with localhost. I've been using localhost in development, so I wasn't aware of this distinction.

Second, Snap Firefox doesn't like "localhost:5000". That's why I found out the page wasn't working. It really wants you to add the protocol -> "http://localhost:5000" works. Apparently, there is no rule that says that localhost must resolve to http://localhost, so Snap Firefox is not wrong.

However, Firefox on OS X does accept "localhost:5000" (by automagically prefixing http://) - just like Safari on OS X or Chromium on Ubuntu. It seems Snap Firefox is the only one out there not adding the http:// string. And I am quite sure that this is a change between Ubuntu 20.04 and 20.10.

For the sake of consistency, I would argue that Snap Firefox should revert to the old behaviour (which is consistent with OS X Firefox), but there are probably good reasons for not doing that.

us flag
As a workaround, switch to the .deb version. `sudo snap remove firefox && sudo apt install firefox`.
in flag
If this is a website that you created, this would be an opportune time to update it to follow proper CORS policies, as it's only a matter of time before all browsers block cross-domain Ajax requests that do not adhere to the HTTP standards
N0rbert avatar
zw flag
Does this answer your question? [21.10 Firefox Missing Profiles](https://askubuntu.com/questions/1369493/21-10-firefox-missing-profiles)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.