redstone.dart

How do you add CORS headers in Redstone interceptor?

∥☆過路亽.° 提交于 2019-12-20 03:04:24
问题 I'm trying to add CORS headers to incoming requests but I've noticed that app.response.headers is an immutable map and app.request.response doesn't exist even though it appears in the documentation examples. So, to the OPTIONS request I'm replying using a new Shelf response, but I can't find a way to add any new headers to the response of the actual request. Any ideas? @app.Interceptor(r"/api/.*", chainIdx: 1) corsInterceptor() { if (app.request.method == "OPTIONS") { var response = new shelf

How do you add CORS headers in Redstone interceptor?

∥☆過路亽.° 提交于 2019-12-02 02:23:28
I'm trying to add CORS headers to incoming requests but I've noticed that app.response.headers is an immutable map and app.request.response doesn't exist even though it appears in the documentation examples. So, to the OPTIONS request I'm replying using a new Shelf response, but I can't find a way to add any new headers to the response of the actual request. Any ideas? @app.Interceptor(r"/api/.*", chainIdx: 1) corsInterceptor() { if (app.request.method == "OPTIONS") { var response = new shelf.Response.ok("", headers: HEADERS); app.chain.interrupt(statusCode: HttpStatus.OK, responseValue: