Skip to content

CORS Issue in AWS Cognito OpenID Endpoints

0

Is it safe to call /.well-known/openid-configuration from AWS Cognito directly from browser? Or can it result in CORS issues? If it can result in CORS, is there any way to customize cors for such cognito end points via AWS API gateway etc.

asked a month ago118 views

1 Answer
0

Yes, the Cognito /.well-known/openid-configuration endpoint is intended to be publicly accessible. It contains OIDC metadata such as the issuer, authorization endpoint, token endpoint, and jwks_uri — no sensitive user data.

The endpoint for a user pool looks like:

https://cognito-idp.<region>.amazonaws.com/<user-pool-id>/.well-known/openid-configuration

AWS specifically documents this endpoint as the OIDC discovery endpoint that applications and OIDC libraries can use for automatic configuration.

However, you cannot customize the CORS headers of Cognito-managed endpoints. Cognito controls those endpoints, and placing API Gateway in front of them would only create your own proxy — it would not modify Cognito's actual CORS configuration.

Also note that Cognito discovery endpoints are hosted on the cognito-idp.<region>.amazonaws.com issuer domain, not on your Cognito custom/hosted UI domain.

So the recommended approach is:

  • Use the Cognito discovery endpoint directly when your OIDC library supports discovery.
  • Don't put API Gateway in front of it just to change CORS.
  • If your browser/framework encounters a CORS limitation, fetch/cache the discovery document from your backend or provide the required OIDC endpoint configuration to the frontend instead.

answered a month ago

EXPERT

reviewed a month ago

  • Thanks for your response. It is helpful. Does that mean we can't call OIDC discovery endpoint from browser directly as it will be blocked by CORS and does same apply to jwks_uri end point also?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.