@@ -47,6 +47,7 @@ import (
47
47
"gitea.com/go-chi/session"
48
48
"github.com/NYTimes/gziphandler"
49
49
"github.com/go-chi/chi/middleware"
50
+ "github.com/go-chi/cors"
50
51
"github.com/prometheus/client_golang/prometheus"
51
52
"github.com/tstranex/u2f"
52
53
"github.com/unknwon/com"
@@ -389,7 +390,18 @@ func RegisterRoutes(m *web.Route) {
389
390
// TODO manage redirection
390
391
m .Post ("/authorize" , bindIgnErr (auth.AuthorizationForm {}), user .AuthorizeOAuth )
391
392
}, ignSignInAndCsrf , reqSignIn )
392
- m .Post ("/login/oauth/access_token" , bindIgnErr (auth.AccessTokenForm {}), ignSignInAndCsrf , user .AccessTokenOAuth )
393
+ if setting .CORSConfig .Enabled {
394
+ m .Post ("/login/oauth/access_token" , cors .Handler (cors.Options {
395
+ //Scheme: setting.CORSConfig.Scheme, // FIXME: the cors middleware needs scheme option
396
+ AllowedOrigins : setting .CORSConfig .AllowDomain ,
397
+ //setting.CORSConfig.AllowSubdomain // FIXME: the cors middleware needs allowSubdomain option
398
+ AllowedMethods : setting .CORSConfig .Methods ,
399
+ AllowCredentials : setting .CORSConfig .AllowCredentials ,
400
+ MaxAge : int (setting .CORSConfig .MaxAge .Seconds ()),
401
+ }), bindIgnErr (auth.AccessTokenForm {}), ignSignInAndCsrf , user .AccessTokenOAuth )
402
+ } else {
403
+ m .Post ("/login/oauth/access_token" , bindIgnErr (auth.AccessTokenForm {}), ignSignInAndCsrf , user .AccessTokenOAuth )
404
+ }
393
405
394
406
m .Group ("/user/settings" , func () {
395
407
m .Get ("" , userSetting .Profile )
0 commit comments