Skip to content

Commit

Permalink
feat: add cors
Browse files Browse the repository at this point in the history
  • Loading branch information
chauanhtuan185 authored Oct 30, 2024
1 parent 33baa14 commit cc5d476
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ const swaggerJsDoc = require('swagger-jsdoc');

const app = express();
const port = process.env.PORT || 3001;
app.use(cors());

const allowedOrigins = ['http://localhost:3000', 'https://buildlink.vercel.app'];

app.use(cors({
origin: 'http://localhost:3000'
origin: function (origin, callback) {
if (!origin || allowedOrigins.includes(origin)) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
}
}));

const options = {
Expand Down

0 comments on commit cc5d476

Please sign in to comment.