Skip to content

Commit

Permalink
Fix BASE_PATH vs PUBLIC_URL discrepancy
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksTeresh committed May 14, 2024
1 parent 5add214 commit a99f28a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG GIT_SHA
ENV REACT_APP_GIT_SHA=$GIT_SHA

ARG BASE_PATH
ENV PUBLIC_URL=$BASE_PATH
ENV BASE_PATH=$BASE_PATH

ARG E2E
ENV REACT_APP_E2E=$E2E
Expand Down
4 changes: 2 additions & 2 deletions src/client/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ThesesPage from './components/ThesisPage/ThesesPage'
import RootBoundary from './components/Errors/RootBoundary'
import NotFound from './components/Errors/NotFound'

import { PUBLIC_URL } from '../config'
import { BASE_PATH } from '../config'

const router = createBrowserRouter(
[
Expand All @@ -27,7 +27,7 @@ const router = createBrowserRouter(
},
],
{
basename: PUBLIC_URL,
basename: BASE_PATH,
}
)

Expand Down
5 changes: 3 additions & 2 deletions src/client/components/ThesisPage/ThesisEditForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useTranslation } from 'react-i18next'
import programs from '../mockPorgrams'
import SupervisorSelect from './SupervisorSelect'
import useUsers from '../../hooks/useUsers'
import { BASE_PATH } from '../../../config'

const VisuallyHiddenInput = styled('input')({
clip: 'rect(0 0 0 0)',
Expand Down Expand Up @@ -231,7 +232,7 @@ const ThesisEditForm: React.FC<{
label={
'filename' in editedThesis.researchPlan ? (
<Link
href={`/api/attachments/${editedThesis.researchPlan.filename}`}
href={`${BASE_PATH}/api/attachments/${editedThesis.researchPlan.filename}`}
>
{editedThesis.researchPlan.name}
</Link>
Expand Down Expand Up @@ -274,7 +275,7 @@ const ThesisEditForm: React.FC<{
label={
'filename' in editedThesis.waysOfWorking ? (
<Link
href={`/api/attachments/${editedThesis.waysOfWorking.filename}`}
href={`${BASE_PATH}/api/attachments/${editedThesis.waysOfWorking.filename}`}
>
{editedThesis.waysOfWorking.name}
</Link>
Expand Down
4 changes: 2 additions & 2 deletions src/client/util/apiClient.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from 'axios'

import { PUBLIC_URL } from '../../config'
import { BASE_PATH } from '../../config'

const baseURL = `${PUBLIC_URL}/api`
const baseURL = `${BASE_PATH}/api`

const apiClient = axios.create({ baseURL })

Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const inE2EMode = process.env.REACT_APP_E2E === 'true'

export const GIT_SHA = process.env.REACT_APP_GIT_SHA || ''

export const PUBLIC_URL = process.env.PUBLIC_URL || ''
export const BASE_PATH = process.env.BASE_PATH || ''

// eslint-disable-next-line no-nested-ternary
export const FULL_URL = inProduction
Expand Down
6 changes: 3 additions & 3 deletions src/server/routes/login.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import express from 'express'
import passport from 'passport'

import { PUBLIC_URL } from '../../config'
import { BASE_PATH } from '../../config'

const loginRouter = express.Router()

loginRouter.get('/', passport.authenticate('oidc'))

loginRouter.get(
'/callback',
passport.authenticate('oidc', { failureRedirect: PUBLIC_URL || '/' }),
passport.authenticate('oidc', { failureRedirect: BASE_PATH || '/' }),
(_, res) => {
res.redirect(PUBLIC_URL || '/')
res.redirect(BASE_PATH || '/')
}
)

Expand Down

0 comments on commit a99f28a

Please sign in to comment.