File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed
Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change 1616# Copyright (C) 2025 Krisna Pranav, MoonScript Developers
1717
1818module MoonScript
19- class CORS
20- include HTTP ::Handler
19+ class CORS
20+ include HTTP ::Handler
21+
22+ def call (context )
23+ # # Response headers which supports the web type.
24+ context.response.headers[" Access-Control-Max-Age" ] = 1 .day.total_seconds.to_i.to_s
25+ context.response.headers[" Access-Control-Allow-Methods" ] = " GET, POST, PUT, PATCH"
26+ context.response.headers[" Access-Control-Allow-Headers" ] = " Content-Type"
27+ context.response.headers[" Access-Control-Allow-Credentials" ] = " true"
28+ context.response.headers[" Access-Control-Allow-Origin" ] = " *"
29+
30+ # # Case checking
31+ if context.request.method.upcase == " OPTIONS"
32+ context.response.content_type = " text/html; charset=utf-8"
33+ context.response.status = :ok
34+ else
35+ call_next context
36+ end
2137
22- def call (context )
23- context.response.headers[" Accept-Control-Max-Age" ] = 1 .day.total_seconds.to_i.to_s
24- context.response.headers[" Acccess-Control-Allow-Method" ] = " GET, POSt, PUT, PATCH"
25- end
2638 end
27- end
39+ end
40+ end
You can’t perform that action at this time.
0 commit comments