https://supertokens.com/ logo
Title
a

alpinjs

02/13/2023, 1:56 PM
hello again,
import express from "express";
import cors from "cors";
import supertokens from "supertokens-node";
import { middleware } from "supertokens-node/framework/express";

let app = express();

app.use(cors({
    origin: "http://localhost:3000",
    allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
    credentials: true,
}));

// IMPORTANT: CORS should be before the below line.
app.use(middleware());

// ...your API routes
i've already set this config on my backend but it still not working. axios said to me cors error.
r

rp

02/13/2023, 1:57 PM
what is the cors error?
a

alpinjs

02/13/2023, 2:00 PM
backend nodejs front end vuejs xhr library axios
n

nkshah2

02/13/2023, 2:00 PM
The browser console will have an error message for this, can you send that?
a

alpinjs

02/13/2023, 2:00 PM
already sent
n

nkshah2

02/13/2023, 2:01 PM
I meant the console, not the network tab
a

alpinjs

02/13/2023, 2:01 PM
sorry 🙂
n

nkshah2

02/13/2023, 2:01 PM
No problem
Right, youre visiting the webpage using your IP and not localhost which is why you are getting an error. You can either visit the page using
localhost:3000
or change your code snippet for cors to
app.use(cors({
    origin: "http://127.0.0.1:3000",
    allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
    credentials: true,
}));
a

alpinjs

02/13/2023, 2:06 PM
it doesnt work
r

rp

02/13/2023, 2:07 PM
whats the response headers from the OPTIONS API?
a

alpinjs

02/13/2023, 2:08 PM
204
r

rp

02/13/2023, 2:10 PM
right. So this seems fine
and the response headers for the POST / GET request?
a

alpinjs

02/13/2023, 2:12 PM
hasnt header because cors error.
r

rp

02/13/2023, 2:12 PM
whats the cors error?
a

Ahmett

02/13/2023, 2:17 PM
hi again, @rp we are teams alpinjs
r

rp

02/13/2023, 2:18 PM
whats shown on the browser console?
right. Which version of the backend SDK are you using? Can you update it to the latest and check again?
i mean the backend SDK version
supertokens-node version
a

alpinjs

02/13/2023, 2:35 PM
"supertokens-node": "^12.1.6"
r

rp

02/13/2023, 2:36 PM
right. You need to update that to 13.0.0
and try again
a

alpinjs

02/13/2023, 2:36 PM
ooops
ok
it works. thanks