File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -190,16 +190,19 @@ func (s *Service) createHandler(schema *graphql.Schema) *graphqlHandler {
190
190
191
191
func (s * Service ) ServeHTTP (w http.ResponseWriter , r * http.Request ) {
192
192
193
- if ( * r ). Method == "OPTIONS" && s .appCfg .Cors .Enabled {
193
+ if s .appCfg .Cors .Enabled {
194
194
allowedOrigins := strings .Join (s .appCfg .Cors .AllowedOrigins , "," )
195
195
allowedHeaders := strings .Join (s .appCfg .Cors .AllowedHeaders , "," )
196
196
w .Header ().Set ("Access-Control-Allow-Origin" , allowedOrigins )
197
197
w .Header ().Set ("Access-Control-Allow-Headers" , allowedHeaders )
198
198
// setting cors allowed methods is not needed for this service,
199
199
// as all graphql methods are part of the cors safelisted methods
200
200
// https://fetch.spec.whatwg.org/#cors-safelisted-method
201
- w .WriteHeader (http .StatusOK )
202
- return
201
+
202
+ if r .Method == http .MethodOptions {
203
+ w .WriteHeader (http .StatusOK )
204
+ return
205
+ }
203
206
}
204
207
205
208
workspace , err := s .parsePath (r .URL .Path )
You can’t perform that action at this time.
0 commit comments