How to enable CORS? #95
-
How to enable cors ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
There are several plugins on CPAN or you can set the headers yourself |
Beta Was this translation helpful? Give feedback.
-
If you hadn't left IRC so abruptly i would have given you a more detailed explanation than you got until then. CORS is just a bunch of headers you could set like To enable CORS indiscriminately for all routes you could just add this hook to your application: app.addContextHook('router:before', async ctx => {
ctx.res.set('Access-Control-Allow-Origin', '*');
}); |
Beta Was this translation helpful? Give feedback.
-
Hi, how to set cors with multiple domain ? Thanks |
Beta Was this translation helpful? Give feedback.
If you hadn't left IRC so abruptly i would have given you a more detailed explanation than you got until then. CORS is just a bunch of headers you could set like
ctx.res.set('Access-Control-Allow-Origin', '*');
. Ideally you would implement CORS as router conditions in an NPM plugin. We have a bunch for Perl already, porting one of them should be very easy.To enable CORS indiscriminately for all routes you could just add this hook to your application: