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
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm config set registry https://registry.npmmirror.com/
|
||||
RUN npm install
|
||||
COPY . .
|
||||
EXPOSE 3000
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
|
||||
import { getAccessTokenGlobal } from '../components/AuthProvider';
|
||||
|
||||
// Backend host: use CRA env var REACT_APP_BACKEND_HOST, or default to localhost.
|
||||
let _backendHost = null;
|
||||
|
||||
export function getBackendHost() {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -21,14 +20,8 @@ export function setBackendHost(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 = {}) {
|
||||
const url = path.startsWith('http') ? path : `${getBackendHost()}${path}`;
|
||||
|
||||
// Attach Authorization header when a token is available
|
||||
const token = getAccessTokenGlobal();
|
||||
if (token) {
|
||||
options.headers = { ...options.headers, Authorization: `Bearer ${token}` };
|
||||
|
||||
Reference in New Issue
Block a user