Skip to content
This repository has been archived by the owner on Dec 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from loyahdev/test-branch
Browse files Browse the repository at this point in the history
add cors code to fix issues
  • Loading branch information
daisuke1227 authored Oct 12, 2024
2 parents ba8d3d0 + f3d5d8a commit a1b1859
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const express = require('express');
const cors = require('cors'); // Add this line
const path = require('path');
const fs = require('fs');
const fileUpload = require('express-fileupload');
Expand All @@ -16,6 +17,19 @@ require('dotenv').config();

const app = express();

// Add this block to configure CORS
const allowedOrigins = ['http://127.0.0.1:8081', 'https://ipasign.pro'];
app.use(cors({
origin: function (origin, callback) {
if (!origin || allowedOrigins.includes(origin)) {
callback(null, true);
} else {
callback(new Error('Not allowed by CORS'));
}
},
credentials: true, // Allow cookies and authentication headers
}));

app.use(CookieP());
app.use(fileUpload({
limits: { fileSize: 5 * 1024 * 1024 * 1024 },
Expand Down

0 comments on commit a1b1859

Please sign in to comment.