0

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.

M_breeb
  • 109

0 Answers0