hello again, ``` import express from "express"; i...
# support-questions-legacy
a
hello again,
Copy code
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
what is the cors error?
a
backend nodejs front end vuejs xhr library axios
n
The browser console will have an error message for this, can you send that?
a
already sent
n
I meant the console, not the network tab
a
sorry 🙂
n
No problem
a
n
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
Copy code
app.use(cors({
    origin: "http://127.0.0.1:3000",
    allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()],
    credentials: true,
}));
a
it doesnt work
r
whats the response headers from the OPTIONS API?
a
204
r
right. So this seems fine
and the response headers for the POST / GET request?
a
hasnt header because cors error.
r
whats the cors error?
a
hi again, @rp_st we are teams alpinjs
r
whats shown on the browser console?
a
r
right. Which version of the backend SDK are you using? Can you update it to the latest and check again?
a
r
i mean the backend SDK version
supertokens-node version
a
"supertokens-node": "^12.1.6"
r
right. You need to update that to 13.0.0
and try again
a
ooops
ok
it works. thanks
2 Views