Skip to content

Improvement: CORS headers #107

@jandusek

Description

@jandusek

I'd be great if CORS headers returned by the local server were set to the same values used by Twilio Runtime once deployed:

access-control-allow-origin: *
access-control-allow-methods: GET, PUT
access-control-max-age: 3000

This would make for a more consistent testing experience.

Something like this might even possibly suffice, although I'm not sure if Functions should be treated differently than Assets.

--- dist/runtime/server.js
+++ dist/runtime/server.js
@@ -45,6 +45,12 @@
         app.use(express_useragent_1.default.express());
         app.use(body_parser_1.default.urlencoded({ extended: false }));
         app.use(body_parser_1.default.json());
+        app.use(function (req, res, next) {
+            res.header("Access-Control-Allow-Origin", "*");
+            res.header("Access-Control-Allow-Methods", "GET, PUT");
+            res.header("Access-Control-Max-Age", "3000");
+            next();
+        });
         app.get('/favicon.ico', (req, res) => {
             res.redirect('https://www.twilio.com/marketing/bundles/marketing/img/favicons/favicon.ico');
         });

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions