Hi I am getting error of cors on my vercel web app...
# general
u
Hi I am getting error of cors on my vercel web app, I have setup cors on my backend properly but it still occurs, can you tell me why thanks.
r
hey @umair_03386 can i see how you have setup the cors middleware on your backend?
u
supertokens.init({ framework: "express", supertokens: { connectionURI: "https://st-dev-369838c0-b579-11ee-99f9-f340bd017302.aws.supertokens.io", apiKey: "WIyZf2oKVE-z7qRJR4Xe0ngH6A", }, appInfo: { appName: "SassySpy", apiDomain: process.env.NODE_ENV === "dev" ? "http://localhost:5000" : "https://api.sassyspy.com", websiteDomain: process.env.NODE_ENV === "dev" ? "http://localhost:5173" : "https://sassyspy-front.vercel.app/", apiBasePath: "/auth", websiteBasePath: "/auth", }, recipeList: [ Passwordless.init({ flowType: "USER_INPUT_CODE", contactMethod: "EMAIL", }), Dashboard.init(), Session.init({ exposeAccessTokenToFrontendInCookieBasedAuth: true, }), UserRoles.init(), ], }); const app = express(); // Connect to the database connectDB(); // Middleware app.use( cors({ origin: process.env.NODE_ENV === "dev" ? "http://localhost:5173" : "https://sassyspy-front.vercel.app/", allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()], credentials: true, }) ); app.use(middleware()); here it is
r
right. You might want to check if there is a cors setting on vercel's dashboard as well.. im not too sure
but this looks right
u
I am doing not nothing else but this on backend, just a simple passwordless email login from frontend
okay let me see
I wasn't any issue before this, it was working fine on vercel
r
im not sure. Sorry. Cors is not directly related to supertokens since another lib is used for it
u
okay so is there anything else that I need to do besides this, it is working fine on my local system
r
nothing that i know of. Might want to as vercel community
u
hmm right, I guess I'll have to research on this a little
thanks for your help
4 Views