CORS - Policy Problem

here is my Node App code app.use( cors({ origin: '*', optionsSuccessStatus: 200, credentials: true, methods: 'GET,PUT,POST,DELETE', }) );
19 Replies
nebula
nebula3y ago
what framework express?
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
yes sir
nebula
nebula3y ago
oh your app is not even up
nebula
nebula3y ago
thats why
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
With this same settings It works in Local Server.
nebula
nebula3y ago
can you send deploy logs for the railway app
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
wait a minute sir
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
It says Active
nebula
nebula3y ago
can you send the code where you call app.listen() change the end to be
// Server
app.listen(process.env.PORT || configs.port, () => {
console.log(
`Server is running at ${process.env.PORT || configs.port} port.`
);
});
// Server
app.listen(process.env.PORT || configs.port, () => {
console.log(
`Server is running at ${process.env.PORT || configs.port} port.`
);
});
deleted the image bc you had secrets in it btw
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
sorry, I don't get it. where I change and what?
nebula
nebula3y ago
change the last part of your code to that delete everything after // Server and paste that instead
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
ok ok Done but I think the code quite same
nebula
nebula3y ago
try redeploying it now should work
nebula
nebula3y ago
yup cors is active now
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
yesss but how?
nebula
nebula3y ago
you were listening on port but you should have been listening on PORT uppercase letters
Saffaullah Shuvo
Saffaullah ShuvoOP3y ago
ohh, Thanks. I put my local variable in .env in lowercase, that's my mistake, thanks for your valuable time sir.
nebula
nebula3y ago
np, glad it works now
Want results from more Discord servers?
Add your server