CORS Handler


This middleware will help you set your CORS options. Based on https://github.com/NozomuIkuta/h3-cors

This middleware will help you solve this security problem.

export interface CorsOptions {    origin?: '*' | 'null' | (string | RegExp)[] | ((origin: string) => boolean);    methods?: '*' | HTTPMethod[];    allowHeaders?: '*' | string[];    exposeHeaders?: '*' | string[];    credentials?: boolean;    maxAge?: string | false;    preflight?: {        statusCode?: number;    };}

To write a custom logic for this middleware follow this pattern:

// nuxt.config.js{  modules: [    "nuxt-security",  ],  security: {    corsHandler: {      value: {        origin: '*',        methods: '*',      },      route: '/my-custom-route'    }  }}