Heyy, We have a nest.js application deployed on R...
# support-questions-legacy
r
Heyy, We have a nest.js application deployed on Railway. In the frontend we have next.js deployed on Vercel. In the backend CORS is set like this
Copy code
app.enableCors({
    origin: [
      '*',
      'http://localhost:3001',
      'http://localhost:3000',
      'https://*.vercel.app',
      'https://*.vercel.app/*',
    ],
    allowedHeaders: ['content-type', ...supertokens.getAllCORSHeaders()],
    credentials: true,
  });
But for all the vercel preview builds, we can't test the app because of CORS issues. Any Idea how to fix it.??
r
Hey @rayhan_rahat
Can I see the response headers in the OPTION Api? And does that actual request get made post that?
r
Here is the options API headers
r
Hmmm. That’s odd
I’m not sure. This is a cors setting. You should ask in the support of your web framework being used.
r
Okay there was two preflights, one passed, one failed, and actual request gets CORS errored
Yeah This is really confusing man -_-
r
Is the supertokens middleware before or after the cors?
r
Before
r
Move the supertokens middleware to after the cors one and try again
r
nope. doesn't work. I think supertokens doesn't have proper support for vercel's dynamic url's I can only test on production/non-dynamic urls
r
That warning has nothing to do with cors setting issues
r
Ahh.. 😐 okay
r
So you should see why the cors isnt applied before the middleware runs
r
okay lemme try some things
Okay I just added this regular expression, and It fixed CORS issues
35 Views