The CORS middleware for PXE.js.
Install @pxe/cors.
# NPM
npm i @pxe/cors
# Yarn
yarn add @pxe/cors
All stuff to handle Cross-origin resource sharing.
CORSoptions?: CORS.Options: The optionsConstruct a CORS middleware.
cors.invokectx: Server.Context: The server contextnext: Server.NextFunction: Call the next middleware...args: any[]: The previous middleware passed argumentsThe callback of the middleware. This can be used as a middleware:
app.use(cors.invoke.bind(cors));
// Or shorter
app.use(cors);
All CORS middleware options.
options.allowOriginsstring | string[]Allows the specified origins to make request to the server. By default all origins are allowed.
options.allowMethodsstring | Server.RequestMethod[]Allow clients to request to the server with specified request method. By default all methods are allowed.
options.exposeHeadersstring | string[]Expose specified headers to the client. Cache-Control, Content-Length, Content-Language, Content-Type, Expires, Last-Modified, Pragma are headers that is exposed by default.
options.maxAgenumberMaximum number of seconds the results can be cached, as an unsigned non-negative integer. The default value is 5.
options.allowCredentialsbooleanIndicates whether or not the response to the request can be exposed when the credentials flag is true. When used as part of a response to a preflight request, this indicates whether or not the actual request can be made using credentials.
options.allowHeadersstring | string[]Indicate which HTTP headers can be used when making the actual request. This field is optional.