nbit icon indicating copy to clipboard operation
nbit copied to clipboard

How to set cors globally?

Open svnty opened this issue 1 year ago • 1 comments

Hello,

How can I set cors globally? In express it would be

app.use(cors());

I have nbit working as such

        return Response.json({ hello: 'world' }, {
          headers: {
            "Access-Control-Allow-Methods": "GET, HEAD, POST, OPTIONS",
            "Access-Control-Allow-Headers": "Content-Type, Accept",
            "Access-Control-Allow-Origin": "https://medicamina.us"
          });

but I don't want to copy paste this boilerplate headers object everywhere, can I set it once and forget about it like app.use(cors())?

svnty avatar Jan 24 '24 04:01 svnty

Currently this isn't possible, but I've implemented a proof of concept in #19, if you have any thoughts.

sstur avatar Jan 26 '24 15:01 sstur