https://supertokens.com/ logo
Title
s

sreehari_jayaraj

03/08/2023, 6:31 PM
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

Snackdex

03/08/2023, 6:33 PM
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

sreehari_jayaraj

03/08/2023, 7:27 PM
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
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

Snackdex

03/08/2023, 7:29 PM
this shouldn't be frontend. how are you deploying this api?
s

sreehari_jayaraj

03/08/2023, 7:30 PM
i am currently running on localhost 8000
s

Snackdex

03/08/2023, 7:31 PM
ok, can you take a screenshot of what you get on the response headers?
s

sreehari_jayaraj

03/08/2023, 7:34 PM
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

Snackdex

03/08/2023, 7:42 PM
rp should come to the rescue. sorry i'm out of my element when it comes to go
s

sreehari_jayaraj

03/08/2023, 7:43 PM
@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

rp

03/09/2023, 5:21 AM
can i see the error on the browser console please?