Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use static middleware and cors middleware together? #9

Open
penggy opened this issue May 2, 2018 · 1 comment
Open

How to use static middleware and cors middleware together? #9

penggy opened this issue May 2, 2018 · 1 comment

Comments

@penggy
Copy link

penggy commented May 2, 2018

How to use static middleware and cors middleware together?

@hmmftg
Copy link

hmmftg commented Jul 28, 2022

    r := gin.Default()
    r.Use(gin.Logger())
    r.Use(gin.Recovery())
    r.Use(cors.New(cors.Config{
	AllowOrigins:     []string{"*"},
	AllowMethods:     []string{"GET", "POST", "PUT"},
	AllowHeaders:     []string{"Origin", "Content-Length", "Content-Type", "Authorization"},
	AllowCredentials: true,
	//AllowAllOrigins:  true,
	MaxAge: 12 * time.Hour,
    }))
    ui := r.Group("/")
    ui.StaticFS("/", http.Dir("./static"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants