mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-17 23:28:50 +00:00
Add .env.example
to React app
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -23,3 +23,6 @@ build
|
|||||||
|
|
||||||
# Ignore the scripts that are created for development
|
# Ignore the scripts that are created for development
|
||||||
*dev.*
|
*dev.*
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
.env
|
||||||
|
@@ -3,6 +3,7 @@ FROM node:14-slim AS site-build
|
|||||||
WORKDIR /app/ui-build
|
WORKDIR /app/ui-build
|
||||||
|
|
||||||
COPY ui .
|
COPY ui .
|
||||||
|
RUN rm .env
|
||||||
RUN npm i
|
RUN npm i
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
2
ui/.env.example
Normal file
2
ui/.env.example
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
REACT_APP_OVERRIDE_WS_URL="ws://localhost:8899/ws"
|
||||||
|
REACT_APP_OVERRIDE_API_URL="http://localhost:8899/api/"
|
@@ -2,17 +2,15 @@ import * as axios from "axios";
|
|||||||
|
|
||||||
const mizuAPIPathPrefix = "/mizu";
|
const mizuAPIPathPrefix = "/mizu";
|
||||||
|
|
||||||
// When working locally (with npm run start) change to:
|
// When working locally cp `cp .env.example .env`
|
||||||
// export const MizuWebsocketURL = `ws://localhost:8899${mizuAPIPathPrefix}/ws`;
|
export const MizuWebsocketURL = process.env.REACT_APP_OVERRIDE_WS_URL ? process.env.REACT_APP_OVERRIDE_WS_URL : `ws://${window.location.host}${mizuAPIPathPrefix}/ws`;
|
||||||
export const MizuWebsocketURL = `ws://${window.location.host}${mizuAPIPathPrefix}/ws`;
|
|
||||||
|
|
||||||
export default class Api {
|
export default class Api {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
// When working locally (with npm run start) change to:
|
// When working locally cp `cp .env.example .env`
|
||||||
// const apiURL = `http://localhost:8899/${mizuAPIPathPrefix}/api/`;
|
const apiURL = process.env.REACT_APP_OVERRIDE_API_URL ? process.env.REACT_APP_OVERRIDE_API_URL : `${window.location.origin}${mizuAPIPathPrefix}/api/`;
|
||||||
const apiURL = `${window.location.origin}${mizuAPIPathPrefix}/api/`;
|
|
||||||
|
|
||||||
this.client = axios.create({
|
this.client = axios.create({
|
||||||
baseURL: apiURL,
|
baseURL: apiURL,
|
||||||
|
Reference in New Issue
Block a user