Express Sweet API Reference - v4.0.0
    Preparing search index...

    Function corsPolicy

    Cross-Origin Resource Sharing (CORS) middleware

    • Mount CORS middleware on Express application.

      Enables Cross-Origin Resource Sharing (CORS) middleware. Allows requests from another domain to the application by setting appropriate headers.

      Parameters

      • app: Express

        Express application instance

      Returns Promise<void>

      // This method is called automatically by express-sweet.mount()
      import corsPolicy from './middlewares/corsPolicy.js';

      await corsPolicy(app);
      // Enable CORS in config/config.js
      export default {
      /**
      * Enable CORS for cross-origin requests, defaults to disabled (false).
      * @type {boolean}
      */
      cors_enabled: true
      };