fix: update CORS to use site's origin on production

This commit is contained in:
Olaleye Blessing 2022-04-19 11:45:29 +01:00
parent 430c6f08ad
commit 2fe682aff3
2 changed files with 9 additions and 3 deletions

View File

@ -1,3 +1,4 @@
NODE_ENV=development
MONGO_DB=mongodb://localhost:27017/urlMinify
SECRET=secret
AUTH_SECRET=secret

View File

@ -10,9 +10,14 @@ require('dotenv').config()
const app = express()
app.use(express.json())
app.use(cors({
origin: 'http://localhost:3000'
}));
app.use(
cors({
origin:
process.env.NODE_ENV?.trim() === 'development'
? 'http://localhost:3000'
: 'https://minfy.xyz',
})
)
app.use(json())
app.use(