Skip to content

Commit

Permalink
Fixes for pathing
Browse files Browse the repository at this point in the history
  • Loading branch information
JPercival committed Apr 27, 2022
1 parent b6014b9 commit 9d9f4cd
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 29 deletions.
4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ PORT=8000
REACT_APP_EPIC_SUPPORTED_QUERIES=false
GENERATE_SOURCEMAP=false
REACT_APP_CDS_MODE=NoCDS
REACT_APP_CDS_URL=http://cloud.alphora.com/rti/r4/cqf-ruler/cds-services
TSC_COMPILE_ON_ERROR=true
ESLINT_NO_DEV_ERRORS=true
REACT_APP_PUBLIC_URL=https://cloud.alphora.com/rti/pain-manager
ESLINT_NO_DEV_ERRORS=true
17 changes: 8 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
FROM node:14 as builder
FROM nginx:1.21.6-alpine

ENV PUBLIC_URL=.
ENV CDS_URL=

RUN mkdir -p /home/node/app && chown -R node:node /home/node/app
WORKDIR /home/node/app
RUN apk add -U --no-cache nghttp2-dev nodejs yarn

RUN mkdir -p /home/node/app
WORKDIR /home/node/app
COPY package*.json ./
COPY yarn.lock ./
USER node
RUN yarn install

COPY --chown=node:node . .
RUN yarn build

FROM nginx:alpine
COPY . .
COPY default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /home/node/app/build/ /usr/share/nginx/html
CMD ["/bin/sh", "-c", "export REACT_APP_CDS_URL=${CDS_URL} && export REACT_APP_PUBLIC_URL=${PUBLIC_URL} && yarn build && cp -r /home/node/app/build/* /usr/share/nginx/html && cd /usr/share/nginx/html && nginx -g \"daemon off;\""]
1 change: 0 additions & 1 deletion public/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"analytics_endpoint": "http://localhost:8000/launch.html",
"x_api_key": "123456789",
"decisionComponent": "internalCDS",
"redcapSurveyLink": "https://www.project-redcap.org/",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class Header extends Component {
return (
<header className="header">
<div className="header__logo">
<img className="header__logo-img" src={`${process.env.REACT_APP_PUBLIC_URL}/assets/images/Pain_Manager_LOGO.jpg`} alt="" />
<img className="header__logo-img" src={`${process.env.PUBLIC_URL}/assets/images/Pain_Manager_LOGO.jpg`} alt="" />
<span className="header__logo-text"></span>
</div>
<div className="header-notice">
Expand Down
2 changes: 1 addition & 1 deletion src/components/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export default class Landing extends Component<any, any> {
});

// Get the configured endpoint to use for POST for app analytics
fetch(process.env.REACT_APP_PUBLIC_URL + '/config.json')
fetch(process.env.PUBLIC_URL + '/config.json')
.then((response: any) => {
return response.json();
})
Expand Down
2 changes: 1 addition & 1 deletion src/components/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class Summary extends Component<any, any> {
this.setState({ appConfig })
} else {

fetch(process.env.REACT_APP_PUBLIC_URL + '/config.json')
fetch(process.env.PUBLIC_URL + '/config.json')
.then((response: any) => { return response.json() })
.then((config: any) => {
this.setState({ appConfig: config })
Expand Down
3 changes: 1 addition & 2 deletions src/containers/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { Route, Switch } from 'react-router-dom';

import App from './App';
import Landing from '../components/Landing';
import pathPrefix from '../helpers/pathPrefix';


const Root = (props) => {
return (
<App>
<Switch>
<Route exact path={pathPrefix + '/'} component={Landing} />
<Route exact path='/' component={Landing} />
</Switch>
</App>
);
Expand Down
7 changes: 0 additions & 7 deletions src/helpers/pathPrefix.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Root from './containers/Root';
import './styles/App.scss';

render(
<Router basename={process.env.REACT_APP_PUBLIC_URL}>
<Router basename={process.env.PUBLIC_URL}>
<Root />
</Router>,
document.getElementById('root')
Expand Down
2 changes: 1 addition & 1 deletion src/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './helpers/polyfill';
import FHIR from 'fhirclient';
require('fetch-everywhere');

fetch(process.env.REACT_APP_PUBLIC_URL + '/launch-context.json')
fetch(process.env.PUBLIC_URL + '/launch-context.json')
.then(function (response) {
return response.json()
}).then(function (launchContext) {
Expand Down
4 changes: 2 additions & 2 deletions src/serviceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const isLocalhost = Boolean(
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.REACT_APP_PUBLIC_URL, window.location.href);
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
Expand All @@ -32,7 +32,7 @@ export function register(config) {
}

window.addEventListener('load', function () {
const swUrl = process.env.REACT_APP_PUBLIC_URL + '/service-worker.ts';
const swUrl = process.env.PUBLIC_URL + '/service-worker.ts';

if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
Expand Down

0 comments on commit 9d9f4cd

Please sign in to comment.