freedomofpress / securedrop-signal-poc

prototype e2e server and source + journalist clients for securedrop
GNU General Public License v3.0
5 stars 3 forks source link

CORS error when attempting to log in as source #26

Open eloquence opened 3 years ago

eloquence commented 3 years ago

When attempting to log in as a source in Firefox or Chrome using the signal-proto-focal server branch, I get the following CORS errors on the console. Firefox error output:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8080/api/v2/register. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8080/api/v2/register. (Reason: CORS request did not succeed). Uncaught (in promise) err: no AuthCred found

(I was able to get it to work by forcibly disabling CORS checks via a browser extension.)

conorsch commented 3 years ago

This has bitten me before, too. Easy to reproduce if you browse to http://localhost:8080 :

sd-e2e-cors-1

However, if you browse to http://127.0.0.1:8080, then the problem doesn't occur:

sd-e2e-cors-2

I believe that's caused by the 127.0.0.1 value being hardcoded in places like https://github.com/freedomofpress/securedrop/blob/08068350941d22e02e8f041ffcb958635da704db/securedrop/static/js/messaging.js#L131