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
nebula2y ago
what framework express?
Saffaullah Shuvo
yes sir
nebula
nebula2y ago
oh your app is not even up
nebula
nebula2y ago
thats why
Saffaullah Shuvo
With this same settings It works in Local Server.
nebula
nebula2y ago
can you send deploy logs for the railway app
Saffaullah Shuvo
wait a minute sir
Saffaullah Shuvo
It says Active
nebula
nebula2y 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
sorry, I don't get it. where I change and what?
nebula
nebula2y ago
change the last part of your code to that delete everything after // Server and paste that instead
Saffaullah Shuvo
ok ok Done but I think the code quite same
nebula
nebula2y ago
try redeploying it now should work
nebula
nebula2y ago
yup cors is active now
Saffaullah Shuvo
yesss but how?
nebula
nebula2y ago
you were listening on port but you should have been listening on PORT uppercase letters
Saffaullah Shuvo
ohh, Thanks. I put my local variable in .env in lowercase, that's my mistake, thanks for your valuable time sir.
nebula
nebula2y ago
np, glad it works now
Want results from more Discord servers?
Add your server