I am seeing this error in the browser running my SPA:
Access to XMLHttpRequest at 'https://naboo.auth0.com/authorize?client_id=xxxxxxDNNEQS2NyxHxYxxxxx&redirect_uri=http%3A%2F%2Flocalhost%3A4004%2Fapi%2Fauth%2Fauth0%2Fcallback&response_type=code&scope=openid+profile+email' (redirected from 'http://localhost:4004/api/auth/auth0') from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Here is the pre-flight request that occurs just before the redirect to Auth0 universal login would occur (and immediately before the CORS error occurs):
Request URL: https://naboo.auth0.com/authorize?client_id=xxxxxxxNNEQS2NyxHxxxxx&redirect_uri=http%3A%2F%2Flocalhost%3A4004%2Fapi%2Fauth%2Fauth0%2Fcallback&response_type=code&scope=openid+profile+email
Request Method: OPTIONS
Remote Address: 34.213.13.63:443
Status Code: 200
Version: HTTP/2
Referrer Policy: no-referrer-when-downgrade
Request Headers:
Host: naboo.auth0.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:77.0) Gecko/20100101 Firefox/77.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Access-Control-Request-Method: GET
Referer: http://localhost:3000/
Origin: http://localhost:3000
Connection: keep-alive
TE: Trailers
Response Headers:
HTTP/2 200 OK
date: Mon, 29 Jun 2020 01:07:19 GMT
content-type: text/plain; charset=utf-8
content-length: 2
server: nginx
ot-tracer-spanid: 1c4f351a49f69bc4
ot-tracer-traceid: 1ce0269e4e251871
ot-tracer-sampled: true
ot-baggage-auth0-request-id: 12b402f6410c035935b8b33e
x-auth0-requestid: db04ae8908a55c2a63b5
set-cookie: did=s%3Av0%3Ae148ef50-b9a4-11ea-8eff-17e93d3f3ab5.x30FKNZU%2Fndsi0I%2FTWeZsyVbZnvsqHzf3QxLCJzEWDc; Max-Age=31557600; Path=/; Expires=Tue, 29 Jun 2021 07:07:19 GMT; HttpOnly; Secure; SameSite=None
set-cookie: did_compat=s%3Av0%3Ae148ef50-b9a4-11ea-8eff-17e93d3f3ab5.x30FKNZU%2Fndsi0I%2FTWeZsyVbZnvsqHzf3QxLCJzEWDc; Max-Age=31557600; Path=/; Expires=Tue, 29 Jun 2021 07:07:19 GMT; HttpOnly; Secure
access-control-max-age: 1000
access-control-allow-methods: GET, PUT, POST, DELETE, PATCH, OPTIONS
access-control-allow-headers: Origin, Content-Type, Accept, X-Requested-With, Authorization, Auth0-Client, X-Request-Language
etag: W/"2-nOO9QiTIwXgNtWtBJezz8kv3SLc"
cache-control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-transform
strict-transport-security: max-age=15724800
x-robots-tag: noindex, nofollow, nosnippet, noarchive
X-Firefox-Spdy: h2
The Access-Control-Allow-Origin
header is not returned by Auth0.
In my Auth0 regular web application I have Allowed Web Origins and Allowed Origins (CORS) both set to http://localhost:3000
and, as you can see from the request above, that is the origin specified in the pre-flight request.
Why is Auth0 not returning Access-Control-Allow-Origin
header with a value of http://localhost:3000
?