fix: use relative URLs for API and WebSocket in production
Browser uses /api and /ws (same origin through Nginx), SSR falls back to localhost:3001 for development. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a2da9cf0f7
commit
1c316a8cd3
@ -4,7 +4,13 @@ import { AppModule } from './app.module';
|
|||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
app.enableCors();
|
app.enableCors({
|
||||||
|
origin: [
|
||||||
|
'https://dev.reckue.com',
|
||||||
|
'http://localhost:3000',
|
||||||
|
],
|
||||||
|
credentials: true,
|
||||||
|
});
|
||||||
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
|
app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));
|
||||||
app.setGlobalPrefix('api');
|
app.setGlobalPrefix('api');
|
||||||
await app.listen(process.env.PORT ?? 3001);
|
await app.listen(process.env.PORT ?? 3001);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001/api';
|
const API_URL = process.env.NEXT_PUBLIC_API_URL || (typeof window !== 'undefined' ? '/api' : 'http://localhost:3001/api');
|
||||||
|
|
||||||
class ApiClient {
|
class ApiClient {
|
||||||
private token: string | null = null;
|
private token: string | null = null;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { io } from 'socket.io-client';
|
import { io } from 'socket.io-client';
|
||||||
|
|
||||||
const WS_URL = process.env.NEXT_PUBLIC_WS_URL || 'http://localhost:3001/ws';
|
const WS_URL = process.env.NEXT_PUBLIC_WS_URL || (typeof window !== 'undefined' ? '/ws' : 'http://localhost:3001/ws');
|
||||||
|
|
||||||
export const socket = io(WS_URL, {
|
export const socket = io(WS_URL, {
|
||||||
autoConnect: false,
|
autoConnect: false,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user