auth0 / auth0-react

Auth0 SDK for React Single Page Applications (SPA)
MIT License
887 stars 256 forks source link

getAccessTokenSilently() included unnecessary headers with custom domain, /oauth/token endpoint throws CORS policy #662

Closed nhien-cerebral closed 11 months ago

nhien-cerebral commented 11 months ago

Checklist

Describe the problem you'd like to have solved

Hi everyone, Currently we are using a custom domain to integrate with our react application. The method getAccessTokenSilently() added some unwanted headers and make a call to /oauth/token. I messaged the auth0 support and they responded to me this one. **It looks like the CORS error in your screenshot is showing the message "request header field x-datadog-origin is not allowed by access-control-allow-headers" on a request to the /oauth/token endpoint.

Unfortunately, /oauth/token endpoint does not accept any other headers apart from the ones listed below:

Origin, Content-Type, Accept, X-Requested-With, Authorization, Auth0-Client, X-Request-Language

It's not possible to allow/add other headers currently**

Screenshot 2023-11-15 at 2 31 29 PM

I tried to disable our datadog implementation and it works properly. It seems like datadog automatically include some headers and the SDK made the call with them.

image

Describe the ideal solution

I think it's better to send only the necessary headers to /oauth/token

Alternatives and current workarounds

No response

Additional context

No response

nhien-cerebral commented 11 months ago

I think we got the answer. Datadog had override some headers and it's the root cause of issue