Skip to content

Commit

Permalink
[#206] feat: add api suffix for all public api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
glemenneo committed Nov 9, 2024
1 parent f09194d commit 2836d2d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
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 }

0 comments on commit 2836d2d

Please sign in to comment.