mirror of
https://github.com/Telecominfraproject/wlan-cloud-ui.git
synced 2025-10-29 01:42:38 +00:00
make API url dynamic
This commit is contained in:
@@ -24,7 +24,11 @@ RUN npm run build
|
||||
|
||||
# production environment
|
||||
FROM nginx:stable-alpine
|
||||
RUN apk add --no-cache jq
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY docker_entrypoint.sh generate_config_js.sh /
|
||||
RUN chmod +x docker_entrypoint.sh generate_config_js.sh
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
ENTRYPOINT ["/docker_entrypoint.sh"]
|
||||
1
app/config.js
Normal file
1
app/config.js
Normal file
@@ -0,0 +1 @@
|
||||
window.REACT_APP_API = undefined;
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
<!-- Allow installing the app to the homescreen -->
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<script type="text/javascript" src="config.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -18,9 +18,7 @@ import { getItem, setItem, removeItem } from 'utils/localStorage';
|
||||
import history from 'utils/history';
|
||||
|
||||
const API_URI =
|
||||
process.env.NODE_ENV === 'development'
|
||||
? 'http://localhost:4000/'
|
||||
: 'https://wlan-graphql.zone3.lab.connectus.ai/';
|
||||
process.env.NODE_ENV === 'development' ? 'http://localhost:4000/' : window.REACT_APP_API;
|
||||
const MOUNT_NODE = document.getElementById('root');
|
||||
|
||||
const cache = new InMemoryCache();
|
||||
|
||||
3
docker_entrypoint.sh
Normal file
3
docker_entrypoint.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh -eu
|
||||
./generate_config_js.sh >/usr/share/nginx/html/config.js
|
||||
nginx -g "daemon off;"
|
||||
10
generate_config_js.sh
Normal file
10
generate_config_js.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh -eu
|
||||
if [ -z "${API:-}" ]; then
|
||||
API_URL_JSON=undefined
|
||||
else
|
||||
API_URL_JSON=$(jq -n --arg api '$API' '$api')
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
window.REACT_APP_API=$API_URL_JSON;
|
||||
EOF
|
||||
Reference in New Issue
Block a user