Access-Control-Allow-Credentials' header in the re...
# support-questions
s
Access-Control-Allow-Credentials' header in the response is '' which must be 'true' is this a csupertokens eror or cors erorr? i am confused
s
this is a cors error
you should be getting this back like this. if you're not then you're going to get that cors error.
s
Copy code
router := gin.Default()
    // cors handling middlewares and supertokens middlewares
    router.Use(gin.Recovery())

    // CORS
    router.Use(cors.New(cors.Config{
        AllowOrigins:     []string{"http://localhost:3000"},
        AllowMethods:     []string{"GET", "POST", "DELETE", "PUT", "OPTIONS"},
        AllowHeaders:     append([]string{"content-type"}, supertokens.GetAllCORSHeaders()...),
        MaxAge:           1 * time.Minute,
        AllowCredentials: true,
    }))

    router.Use(middlewares.Supertokens())

    // use ginSwagger middleware to serve the API docs
    router.GET("/", func(c *gin.Context) {
        res := map[string]interface{}{
            "data": "Server is up and running",
            "ok":   true,
        }
        c.JSON(http.StatusOK, res)
    })
still the web throwing cors error
i have been trying to solve this last 4 hours
my middlewares.supertokens looks like
Copy code
func Supertokens() gin.HandlerFunc {
    return gin.HandlerFunc(func(c *gin.Context) {
        supertokens.Middleware(http.HandlerFunc(
            func(rw http.ResponseWriter, r *http.Request) {

                c.Next()
            })).ServeHTTP(c.Writer, c.Request)
        // we call Abort so that the next handler in the chain is not called, unless we call Next explicitly
        c.Abort()
    })
}
should i do something on front end ?
s
this shouldn't be frontend. how are you deploying this api?
s
i am currently running on localhost 8000
s
ok, can you take a screenshot of what you get on the response headers?
s
pre fligth is working fine
should i try chnagint the version of supertokens ?
its 1.11 am in morning here so i am leaving, if anyone can help please help 😢😢😢
s
rp should come to the rescue. sorry i'm out of my element when it comes to go
s
@rp please help🥲
https://github.com/sreehari2003/kseb Here is my code i have changed few code like moved all middle ware before declaring api routes etc, btw i love super tokens we have build few apps on super tokens with nest js. This is my first time using it with gonlang
r
can i see the error on the browser console please?
3 Views