Skip to content

Commit d88597b

Browse files
authored
Adding relative path (#142)
* Adding relative URL
1 parent 73d7c3f commit d88597b

File tree

7 files changed

+28
-4
lines changed

7 files changed

+28
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
shell: bash
3131
run: |
3232
oc project ${{ secrets.OPENSHIFT_REPOSITORY }}-tools
33+
CURRENT_DATE=$(date +"%d_%m_%Y")
34+
oc tag condition-api:${{ github.event.inputs.environment }} condition-api:${{ github.event.inputs.environment }}_bkp_${CURRENT_DATE}
35+
oc tag condition-web:${{ github.event.inputs.environment }} condition-web:${{ github.event.inputs.environment }}_bkp_${CURRENT_DATE}
3336
oc tag condition-api:latest condition-api:${{ github.event.inputs.environment }}
3437
oc tag condition-web:latest condition-web:${{ github.event.inputs.environment }}
3538

condition-web/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ FROM node:16-alpine as build-stage
55
# set working directory
66
WORKDIR /app
77

8+
# Build argument for base path
9+
ARG VITE_APP_BASE_PATH=/conditions
10+
ENV VITE_APP_BASE_PATH=$VITE_APP_BASE_PATH
11+
812
# add `/app/node_modules/.bin` to $PATH
913
ENV PATH /app/node_modules/.bin:$PATH
1014

condition-web/nginx/nginx.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,20 @@ http {
4848
listen 8080;
4949
server_name _;
5050

51+
# Prevent nginx from adding internal port to redirects
52+
absolute_redirect off;
53+
port_in_redirect off;
54+
5155
index index.html;
5256
error_log /dev/stdout info;
5357
access_log /dev/stdout;
5458

59+
location /conditions {
60+
alias /usr/share/nginx/html;
61+
index index.html index.htm;
62+
try_files $uri $uri/ /conditions/index.html;
63+
}
64+
5565
location / {
5666
root /usr/share/nginx/html;
5767
index index.html index.htm;

condition-web/src/components/Unauthorized.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react";
22
import { Box, Typography, Link } from "@mui/material";
33
import { BCDesignTokens } from "epic.theme";
4+
import { AppConfig } from "@/utils/config";
45

56
const Unauthorized: React.FC = React.memo(() => {
67
return (
@@ -51,10 +52,10 @@ const Unauthorized: React.FC = React.memo(() => {
5152
If you believe you should have access to Condition Repository, please
5253
contact the Environmental Assessment Office at
5354
<Link
54-
href="mailto:EAO.ManagementPlanSupport@gov.bc.ca"
55+
href={`mailto:${AppConfig.supportEmail}`}
5556
sx={{ ml: BCDesignTokens.layoutMarginXsmall }}
5657
>
57-
EAO.ManagementPlanSupport@gov.bc.ca.
58+
{AppConfig.supportEmail}
5859
</Link>
5960
</Typography>
6061
</Box>

condition-web/src/router.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { createRouter, RouterProvider } from "@tanstack/react-router";
22
import { routeTree } from "@/routeTree.gen";
33
import { useAuth } from "react-oidc-context";
4+
import { AppConfig } from "./utils/config";
45

56
// Create a new router instance
67
const router = createRouter({
8+
basepath: AppConfig.appBasePath,
79
routeTree,
810
context: {
911
// authentication will initially be undefined

condition-web/src/utils/config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare global {
88
VITE_VERSION: string;
99
VITE_APP_TITLE: string;
1010
VITE_APP_URL: string;
11+
VITE_APP_BASE_PATH: string;
1112
VITE_OIDC_AUTHORITY: string;
1213
VITE_CLIENT_ID: string;
1314
VITE_SUPPORT_EMAIL: string;
@@ -23,6 +24,7 @@ const APP_VERSION =
2324
const APP_TITLE =
2425
window._env_?.VITE_APP_TITLE || import.meta.env.VITE_APP_TITLE || "";
2526
const APP_URL = window._env_?.VITE_APP_URL || import.meta.env.VITE_APP_URL;
27+
const APP_BASE_PATH = window._env_?.VITE_APP_BASE_PATH || import.meta.env.VITE_APP_BASE_PATH;
2628
const OIDC_AUTHORITY =
2729
window._env_?.VITE_OIDC_AUTHORITY || import.meta.env.VITE_OIDC_AUTHORITY;
2830
const CLIENT_ID =
@@ -36,6 +38,7 @@ export const AppConfig = {
3638
version: APP_VERSION,
3739
appTitle: APP_TITLE,
3840
appUrl: APP_URL,
41+
appBasePath: APP_BASE_PATH,
3942
clientId: CLIENT_ID,
4043
supportEmail: SUPPORT_EMAIL,
4144
};
@@ -44,8 +47,8 @@ export const OidcConfig = {
4447
authority: OIDC_AUTHORITY,
4548
kc_idp_hint: "idir",
4649
client_id: CLIENT_ID,
47-
redirect_uri: `${APP_URL}/oidc-callback`,
48-
post_logout_redirect_uri: `${APP_URL}/`,
50+
redirect_uri: `${APP_URL}${APP_BASE_PATH || ''}/oidc-callback`,
51+
post_logout_redirect_uri: `${APP_URL}${APP_BASE_PATH || ''}/`,
4952
scope: "openid profile email",
5053
revokeTokensOnSignout: true,
5154
userStore: new WebStorageStateStore({ store: window.sessionStorage }),

condition-web/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import istanbul from "vite-plugin-istanbul";
66
// https://vitejs.dev/config/
77

88
export default defineConfig({
9+
base: process.env.VITE_APP_BASE_PATH || "/",
910
plugins: [
1011
TanStackRouterVite(),
1112
react(),

0 commit comments

Comments
 (0)