mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 09:00:19 +00:00
1.7 KiB
1.7 KiB
title |
---|
CORS |
Cross-Origin Resource Sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts, JavaScript, etc.) on a web page to be requested from another domain outside the domain from which the resource originated.
Configuration
Configuration:
- Key:
cors
- Environment:
development
- Location:
./config/environments/development/security.json
- Type:
object
Example:
{
"cors": {
"origin": true,
"expose": [
"WWW-Authenticate",
"Server-Authorization"
],
"maxAge": 31536000,
"credentials": true,
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"OPTIONS",
"HEAD"
],
"headers": [
"Content-Type",
"Authorization"
]
}
}
Options:
origin
(string|boolean): Configures theAccess-Control-Allow-Origin
CORS header. Expects a string (ex:http://example.com
) or a boolean. Set totrue
to reflect the request origin, as defined byreq.header('Origin')
. Set tofalse
to disable CORS.expose
(array): Configures theAccess-Control-Expose-Headers
CORS header. Set this to pass the header, otherwise it is omitted.maxAge
(integer): Configures theAccess-Control-Max-Age
CORS header. Set to an integer to pass the header, otherwise it is omitted.credentials
(boolean): Configures theAccess-Control-Allow-Credentials
CORS header. Set totrue
to pass the header, otherwise it is omitted.methods
(array): Configures theAccess-Control-Allow-Methods
CORS header.headers
(array): Configures theAccess-Control-Allow-Headers
CORS header. If not specified, defaults to reflecting the headers specified in the request'sAccess-Control-Request-Headers
header.
Notes:
- Set to
false
to disable CORS.