Function unstable_createCorsMiddleware

  • Creates a middleware function that applies CORS headers to the response.

    You can customize the CORS options by passing an object with the following properties:

    • origin: The origin(s) allowed to access the resource. This can be a string, boolean, or an array of strings or regular expressions.
    • methods: The HTTP methods allowed for cross-origin requests.
    • allowedHeaders: The headers allowed in the request.
    • exposedHeaders: The headers exposed to the client.
    • credentials: Whether to include credentials in the request.
    • maxAge: The maximum age of the preflight request in seconds.

    Parameters

    Returns unstable_createCorsMiddleware.ReturnType

    A middleware function that applies CORS headers