Skip to content

Commit

Permalink
Merge pull request #106 from pvdthings/dev
Browse files Browse the repository at this point in the history
Release: Security Update
  • Loading branch information
dillonfagan authored Jan 11, 2025
2 parents ee7b414 + 4914d3d commit 8dd8ac2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
deploy-api:
name: Deploy API
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: akhileshns/heroku-deploy@v3.13.15
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
deploy-api:
name: Deploy API
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: akhileshns/heroku-deploy@v3.13.15
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pvdthings-api",
"version": "1.22.0",
"version": "1.22.1",
"description": "",
"main": "server.js",
"scripts": {
Expand Down
10 changes: 9 additions & 1 deletion apps/api/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const lending = require('./apps/librarian');
const cors = require('cors');
const apiKeyMiddleware = require('./middleware/apiKey');

const allowedOrigins = process.env.ACCESS_CONTROL_ALLOW_ORIGIN.split(',');

const corsOptions = Object.freeze({
allowedHeaders: [
'Origin',
Expand All @@ -24,7 +26,13 @@ const corsOptions = Object.freeze({
'supabase-refresh-token'
],
credentials: true,
origin: process.env.ACCESS_CONTROL_ALLOW_ORIGIN
origin: (origin, callback) => {
if (allowedOrigins.includes(origin) || (!origin && isDevelopment())) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
}
});

app.use(cors(corsOptions));
Expand Down

0 comments on commit 8dd8ac2

Please sign in to comment.