File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,15 @@ import (
1313const SentryQueueName = "external/sentry"
1414const CatcherType = "external/sentry"
1515
16+ // helper for CORS
17+ func allowCORS (ctx * fasthttp.RequestCtx ) {
18+ h := & ctx .Response .Header
19+ h .Set ("Access-Control-Allow-Origin" , "*" )
20+ h .Set ("Access-Control-Allow-Methods" , "POST, OPTIONS" )
21+ h .Set ("Access-Control-Allow-Headers" , "Content-Type, X-Sentry-Auth" )
22+ h .Set ("Access-Control-Max-Age" , "86400" )
23+ }
24+
1625// HandleHTTP processes HTTP requests with JSON body
1726func (handler * Handler ) HandleSentry (ctx * fasthttp.RequestCtx ) {
1827 if ctx .Request .Header .ContentLength () > handler .MaxErrorCatcherMessageSize {
@@ -21,6 +30,12 @@ func (handler *Handler) HandleSentry(ctx *fasthttp.RequestCtx) {
2130 return
2231 }
2332
33+ allowCORS (ctx )
34+ if string (ctx .Method ()) == fasthttp .MethodOptions {
35+ ctx .SetStatusCode (fasthttp .StatusNoContent ) // 204
36+ return
37+ }
38+
2439 var hawkToken string
2540 var err error
2641
You can’t perform that action at this time.
0 commit comments