Compare commits
1 Commits
bd03492ef4
...
f9665c92ce
| Author | SHA1 | Date | |
|---|---|---|---|
| f9665c92ce |
@@ -1,8 +1,7 @@
|
|||||||
FROM docker.m.daocloud.io/library/node:21-alpine
|
FROM dnode:21-alpine
|
||||||
RUN apk add --no-cache bash
|
RUN apk add --no-cache bash
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
RUN npm config set registry https://registry.npmmirror.com/
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
COPY . .
|
COPY . .
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
@@ -8,12 +8,11 @@
|
|||||||
|
|
||||||
import { getAccessTokenGlobal } from '../components/AuthProvider';
|
import { getAccessTokenGlobal } from '../components/AuthProvider';
|
||||||
|
|
||||||
// Backend host: use CRA env var REACT_APP_BACKEND_HOST, or default to localhost.
|
|
||||||
let _backendHost = null;
|
let _backendHost = null;
|
||||||
|
|
||||||
export function getBackendHost() {
|
export function getBackendHost() {
|
||||||
if (_backendHost !== null) return _backendHost;
|
if (_backendHost !== null) return _backendHost;
|
||||||
_backendHost = process.env.REACT_APP_BACKEND_HOST || 'http://localhost:8000';
|
_backendHost = process.env.DIALECTIC_REACT_APP_BACKEND_HOST || 'http://localhost:8000';
|
||||||
return _backendHost;
|
return _backendHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,14 +20,8 @@ export function setBackendHost(host) {
|
|||||||
_backendHost = host;
|
_backendHost = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Thin wrapper around fetch() that checks for the 503 "not configured"
|
|
||||||
* response and fires a global event when detected.
|
|
||||||
*/
|
|
||||||
export async function apiFetch(path, options = {}) {
|
export async function apiFetch(path, options = {}) {
|
||||||
const url = path.startsWith('http') ? path : `${getBackendHost()}${path}`;
|
const url = path.startsWith('http') ? path : `${getBackendHost()}${path}`;
|
||||||
|
|
||||||
// Attach Authorization header when a token is available
|
|
||||||
const token = getAccessTokenGlobal();
|
const token = getAccessTokenGlobal();
|
||||||
if (token) {
|
if (token) {
|
||||||
options.headers = { ...options.headers, Authorization: `Bearer ${token}` };
|
options.headers = { ...options.headers, Authorization: `Bearer ${token}` };
|
||||||
|
|||||||
Reference in New Issue
Block a user