Fix: support coop FQDN for dashboard access
This commit is contained in:
@@ -23,9 +23,15 @@ import { setupSocketHandlers } from './services/socket';
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const httpServer = createServer(app);
|
const httpServer = createServer(app);
|
||||||
|
const allowedOrigins = [
|
||||||
|
process.env.FRONTEND_URL,
|
||||||
|
'https://coop.hobokenchicken.com',
|
||||||
|
'http://172.20.1.238:3000'
|
||||||
|
].filter(Boolean) as string[];
|
||||||
|
|
||||||
const io = new Server(httpServer, {
|
const io = new Server(httpServer, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: process.env.FRONTEND_URL || 'http://localhost:3000',
|
origin: allowedOrigins,
|
||||||
credentials: true
|
credentials: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -35,7 +41,7 @@ app.use(helmet({
|
|||||||
crossOriginResourcePolicy: { policy: "cross-origin" }
|
crossOriginResourcePolicy: { policy: "cross-origin" }
|
||||||
}));
|
}));
|
||||||
app.use(cors({
|
app.use(cors({
|
||||||
origin: true, // Allow all origins in dev to fix the IP issue
|
origin: allowedOrigins,
|
||||||
credentials: true
|
credentials: true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001';
|
const API_URL = process.env.NEXT_PUBLIC_API_URL || (typeof window !== 'undefined' ? `${window.location.origin}/api` : 'http://localhost:3001/api');
|
||||||
|
|
||||||
export const api = axios.create({
|
export const api = axios.create({
|
||||||
baseURL: `${API_URL}/api`,
|
baseURL: `${API_URL}/api`,
|
||||||
|
|||||||
Reference in New Issue
Block a user