CORS - Policy Problem

In local server(node and react are in different port), it works fine; but when I request from railway this happen. I have installed npm cors; const cors = require('cors'); app.use(cors());
9 Replies
Percy
Percy3y ago
Please provide your project ID or reply with N/A. Thread will automatically be closed if no reply is received within 10 minutes. You can copy your project's id by pressing Ctrl/Cmd + K -> Copy Project ID.
Percy
Percy3y ago
No project ID was provided. Closing thread.
Dhananjay
Dhananjay3y ago
set origin as * app.use(cors({ origin: * , optionsSuccessStatus: 200, credentials: true })) don't forget to change origin when you are ready to deploy your frontend
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
I think, you mean "*", Ok let me try Brother this is still usolved. help me
CookieMonzteh
CookieMonzteh10mo ago
Ok so then this is specifically a railway app issue then? ideally you should be setting your frontend url as the origin and not the * because thats crazy unsafe
app.use(
cors({
origin: [process.env.FRONTEND_URL],
methods: ["GET", "POST", "PUT", "DELETE"],
credentials: true,
})
);
app.use(
cors({
origin: [process.env.FRONTEND_URL],
methods: ["GET", "POST", "PUT", "DELETE"],
credentials: true,
})
);
having the same exact issue man as if hosting isnt annoying enough
Medim
Medim10mo ago
That's CORS, nothing to do with railway itself, what about you open your own thread and we try to help you?
CookieMonzteh
CookieMonzteh10mo ago
Thought it did considering its only an issue when hosting. Looks liek the same exact problem but will do 👍 just made it
Medim
Medim10mo ago
I'm not at home rn i'll see that thread when possible :salute: I'm sure someone will help u till then
CookieMonzteh
CookieMonzteh10mo ago
no worries, I gtg to work too. Thanks :salute:
Want results from more Discord servers?
Add your server