Arthur Fiorette
08/29/2024, 9:20 PMAccess-Control-Allow-Origin
header is being sent twice, which then throws a CORS error for any request sent to it.
Access to fetch at '<https://zephyr-cerbos-dev.zephyr-cloud.io/api/check/resources>' from origin '<http://localhost:3000>' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, <http://dev.zephyr-cloud.io|dev.zephyr-cloud.io>', but only one is allowed. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
What's the fastest way to debug and solve this issue?Dennis (Cerbos)
server -> cors
section of your Cerbos config?Dennis (Cerbos)
Arthur Fiorette
08/30/2024, 12:12 PMOPTIONS
requests have no CORS
headers in the response.Arthur Fiorette
08/30/2024, 12:13 PMserver:
adminAPI:
enabled: true
adminCredentials:
username: <username>
passwordHash: <hash>
Arthur Fiorette
08/30/2024, 12:13 PMArthur Fiorette
08/30/2024, 12:18 PM*
but our problem was that on Firefox browsers a preflight request was being made (on Chromium only the POST
is being sent) and in this OPTIONS request, a 501 Method Now Allowed
was being sent without any cors headersArthur Fiorette
08/30/2024, 12:21 PMDennis (Cerbos)
cors
section to your server config?
server:
cors: # CORS defines the CORS configuration for the server.
allowedHeaders: ['content-type', 'user-agent'] # AllowedHeaders is the contents of the allowed-headers header.
allowedOrigins: ['*'] # AllowedOrigins is the contents of the allowed-origins header.
disabled: false # Disabled sets whether CORS is disabled.
maxAge: 10s # MaxAge is the max age of the CORS preflight check.