node-sdk icon indicating copy to clipboard operation
node-sdk copied to clipboard

cors support for api resource

Open davemooreuws opened this issue 1 year ago • 1 comments

Feature Request

Suggestion

Add cors middleware handling to the api resource. Enabled by default, with the ability to override headers. It should also auto generate the options handlers per route.

import { api } from '@nitric/sdk';

const mainApi = api('main', {
  cors: {
    allowOrigins: ['*'],
    allowMethods: ['PATCH', 'POST'],
    allowHeaders: ['*'],
    allowCredentials: true,
    maxAge: '300 seconds'
  },
});

Value

Reduces the amount of boilerplate code in users apps.

davemooreuws avatar Oct 16 '23 05:10 davemooreuws