Skip to content

Commit

Permalink
Protect functions through CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
Irenej Bozovicar committed Jan 8, 2024
1 parent 9397b1a commit a2dc3ca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ const routes = require('./routes'); // Adjust the path

const app = express();

// Enable CORS
app.use(cors());
const isProduction = process.env.NODE_ENV === 'production';

// Enable CORS with dynamic origin configuration
const corsOptions = {
origin: isProduction ? 'https://wordclips.org' : true, // Set to true for development
};

// Use CORS middleware with dynamic options
app.use(cors(corsOptions));

app.use('/', routes); // Use the routes

Expand Down

0 comments on commit a2dc3ca

Please sign in to comment.