diff --git a/frontend/components/dashboard/new-session.tsx b/frontend/components/dashboard/new-session.tsx index 515c07d052..15b8b6f580 100644 --- a/frontend/components/dashboard/new-session.tsx +++ b/frontend/components/dashboard/new-session.tsx @@ -82,7 +82,7 @@ export const NewSession = () => { // Refactor this const wsUrl = (process.env.NEXT_PUBLIC_API_URL || 'ws://localhost:3006')?.concat( - `/matching/ws/?id=${websocketId}` + `/api/matching/ws/?id=${websocketId}` ) const socket = new WebSocket(wsUrl) setTimeout(() => { diff --git a/frontend/pages/api/auth/[...nextauth].ts b/frontend/pages/api/auth/[...nextauth].ts index c46d6be6b8..ccae3f1646 100644 --- a/frontend/pages/api/auth/[...nextauth].ts +++ b/frontend/pages/api/auth/[...nextauth].ts @@ -24,7 +24,7 @@ export default NextAuth({ try { const api = axios.create({ - baseURL: process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3002', + baseURL: process.env.NEXT_PUBLIC_API_URL?.concat('/api') ?? 'http://localhost:3002', }) const response = await api.post('/auth/login', { usernameOrEmail: username, password }) diff --git a/frontend/pages/code/editor.tsx b/frontend/pages/code/editor.tsx index f57cd5f51d..7e73465ffa 100644 --- a/frontend/pages/code/editor.tsx +++ b/frontend/pages/code/editor.tsx @@ -52,7 +52,7 @@ const CodeMirrorEditor = forwardRef(({ roomId, language }: IProps, ref) => { const token = session.user.accessToken if (!token) return undefined const wsProvider = new WebsocketProvider( - process.env.NEXT_PUBLIC_API_URL?.concat('/collab/y/ws') ?? 'ws://localhost:3008', + process.env.NEXT_PUBLIC_API_URL?.concat('/api/collab/y/ws') ?? 'ws://localhost:3008', roomId, ydoc, { diff --git a/frontend/services/axios-middleware.ts b/frontend/services/axios-middleware.ts index 7894b7d640..02d93b693d 100644 --- a/frontend/services/axios-middleware.ts +++ b/frontend/services/axios-middleware.ts @@ -38,9 +38,11 @@ const createServiceAPI = (baseURL: string) => { return api } -const userServiceAPI = createServiceAPI(process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3002') -const questionServiceAPI = createServiceAPI(process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3004') -const matchingServiceAPI = createServiceAPI(process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3006') -const collaborationServiceAPI = createServiceAPI(process.env.NEXT_PUBLIC_API_URL ?? 'http://localhost:3008') +const userServiceAPI = createServiceAPI(process.env.NEXT_PUBLIC_API_URL?.concat('/api') ?? 'http://localhost:3002') +const questionServiceAPI = createServiceAPI(process.env.NEXT_PUBLIC_API_URL?.concat('/api') ?? 'http://localhost:3004') +const matchingServiceAPI = createServiceAPI(process.env.NEXT_PUBLIC_API_URL?.concat('/api') ?? 'http://localhost:3006') +const collaborationServiceAPI = createServiceAPI( + process.env.NEXT_PUBLIC_API_URL?.concat('/api') ?? 'http://localhost:3008' +) export default { userServiceAPI, questionServiceAPI, matchingServiceAPI, collaborationServiceAPI } diff --git a/nginx/templates/local-nginx.conf.template b/nginx/templates/local-nginx.conf.template index ba0a8511ad..a6122d34be 100644 --- a/nginx/templates/local-nginx.conf.template +++ b/nginx/templates/local-nginx.conf.template @@ -18,6 +18,10 @@ http { proxy_set_header Upgrade ${D}http_upgrade; proxy_set_header Connection "upgrade"; + location /api/ { + rewrite ^/api(/.*)$ $1 last; + } + location /auth { proxy_pass ${USER_SERVICE_URL}; }