Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

206 be fix nginx routing for deployment and dev #213

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/components/dashboard/new-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/code/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand Down
10 changes: 6 additions & 4 deletions frontend/services/axios-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
4 changes: 4 additions & 0 deletions nginx/templates/local-nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
Expand Down
Loading