fix: update CORS to use site's origin on production (#140)

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

* fix: checking CORS preview mode
This commit is contained in:
Olaleye Blessing 2022-04-19 13:08:51 +01:00 committed by GitHub
parent acd29e95cf
commit 1b5389e06c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 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,15 @@ 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://url-minify-git-fork-olaleye-blessing-fixurlminified-bravo68web.vercel.app'
: 'https://minfy.xyz',
})
)
app.use(json())
app.use(