#Production CORS error on POST

8 messages · Page 1 of 1 (latest)

grizzled storm
#

I have the API deployed in railway and the storefront in Vercel, have the STORE_CORS env well set. I don't know why i get this cors error. This happened to anyone else?

gritty anvil
#

It's a custom route. Have you added cors to the route?

grizzled storm
#

yes how can i fix it?

#

in local works perfectlly. its just in production

paper cipher
cerulean burrow
#

@grizzled storm I believe part of your issue is that your next app is configured to hit https://oblik.fit, but something is sitting in front of it and redirecting to https://www.oblik.fit.

So If I hit:

curl 'https://oblik.fit/api/trpc/variant.search?batch=1&input=%7B%220%22%3A%7B%22q%22%3A%22test%22%2C%22region_id%22%3A%22reg_01HH8EBNVE93X9RB7B1Z9FGCFT%22%2C%22offset%22%3A0%2C%22limit%22%3A2%7D%7D' \
  -H 'sec-ch-ua: "Chromium";v="127", "Not)A;Brand";v="99"' \
  -H 'content-type: application/json' \
  -H 'Referer: https://www.oblik.fit/' \
  -H 'DNT: 1' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -v

notice that no CORS headers are coming back, so the browser is blocking it.

If you change your base url to hit https://www.oblik.fit those CORS issues should disappear.

grizzled storm
#

@cerulean burrow Man you saved my life. I been with this issue and posting it for months.

Is weir because I added both urls to the Store CORS env (with and without "www"). But yeah that solved my issue. You are the GOAT 🐐

cerulean burrow
#

Oh good, glad I could help!