boolean | import('cors').CorsOptions
false
>= 1.1.11
Configure CORS options for the dev server or preview server, based on the cors middleware.
true
:Enable CORS with default options.false
:Disable CORS.object
:Enable CORS with the specified options.Although cors
can be set to true
, we recommend setting a specified origin
option to prevent untrusted origins from accessing your dev server.
The cors
option can be an object, which is the same as the cors middleware options.
The default configuration is the equivalent of:
The origin
option is used to configure the Access-Control-Allow-Origin
header:
Specify multiple allowed origins using an array:
Use a regular expression to allow all matching origins:
Setting origin
to a function allows you to dynamically determine the allowed origin, the function receives two parameters:
origin
:The origin of the incoming request, undefined
if no origin is present.callback
:A function to set the allowed origin.