I have the following bit of code:
const production = process.env.PRODUCTION
console.log(production)
const corsOptions = {
origin: production ? 'https://myproductionurl' : 'http://localhost:3000',
credentials: true
}
console.log(corsOptions)
app.use(cors(corsOptions))
When I run this code the first console.log is returning false as desired however the second console.log statement is returning the production URL as if the variable is true.
Not sure why this is if someone spots something then please let me know!
Furthermore, if I remove the ternary and URLs to test what's going on then i will get origin: false in the corsOptions which is stumping me even more!