Skip to content

Commit

Permalink
Stricter cors policy
Browse files Browse the repository at this point in the history
  • Loading branch information
me3zaAKAgoat committed Mar 30, 2024
1 parent 682608b commit be83f90
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions backend/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ import path from 'path';

const app = express();

app.use(cors());
const allowedOrigins = ["https://dtboard.tech", "https://www.dtboard.tech"]

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

app.use(express.json());
app.use(middleware.requestLogger);

Expand All @@ -36,8 +47,6 @@ app.use(
taskRouter,
);

console.log('dirname', __dirname);

app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'build/index.html'));
});
Expand Down

0 comments on commit be83f90

Please sign in to comment.