-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
CORS doesn't work #59
Comments
Hi @guerinoni ! Are your routes declared before or after the middleware registration ? |
Does not matter, i see the same problem |
func (s *Server) Run() error {
go s.generateOpenAPI()
elapsed := time.Since(s.startTime)
slog.Debug("Server started in "+elapsed.String(), "info", "time between since server creation (fuego.NewServer) and server startup (fuego.Run). Depending on your implementation, there might be things that do not depend on fuego slowing start time")
slog.Info("Server running ✅ on http://localhost"+s.Server.Addr, "started in", elapsed.String())
s.Server.Handler = cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
AllowedHeaders: []string{"*"},
}).Handler(s.Mux)
return s.Server.ListenAndServe()
} This fixes the problem |
Sorry I cannot reproduce. I noticed having CORS issues when having a 405 response, is it your case ? |
I'm not able to make it work, can you attach your front end application? I can try with your code |
Can you show me the network error ? I want to see the preflight request |
This is a 405 return code, are you sure that you are calling the correct METHOD for the /signup route? |
To Reproduce
Steps to reproduce the behavior:
Take the basic example and just add
Expected behavior
I have a front end running on
localhost:3000
and hitting backend inlocalhost:8080
, I got the error about missing CORS.If I switch to another example i tried without fuego it is working
Screenshots
Framework version (please check if it happens with the last Fuego version before posting):
Latest 0.12
Go version (please check if it happens with the last Go version before posting):
Latest: go version go1.22.0 darwin/arm64
The text was updated successfully, but these errors were encountered: