fix(web): stabilize local sign-in and page lifecycle handling
This commit is contained in:
parent
3a290cc8a7
commit
0874e44c12
7 changed files with 79 additions and 17 deletions
|
|
@ -32,6 +32,8 @@ bun run --cwd apps/stock/orchestrator dev
|
|||
|
||||
Run these in separate terminals from the repository root. The frontend alone does not run backtests; the API and orchestrator handle admission and execution. Ingestion and pipeline are additional entrypoints when you need to collect source data or synchronize the catalog.
|
||||
|
||||
Open `http://localhost:5173` and sign in with `STOCK_BOT_ADMIN_TOKEN` from the root `.env`. Both `STOCK_BOT_ADMIN_TOKEN` and `STOCK_BOT_SERVICE_TOKEN` must be configured as distinct values of at least 32 characters before starting HTTP services. The API uses port `2003`; the orchestrator uses `2004`. The frontend has a fixed port to avoid colliding with Docker's Grafana (`3000`) and Bull Board (`3001`) or silently moving to an unapproved browser origin.
|
||||
|
||||
Stock configuration is loaded by [config-instance.ts](config/src/config-instance.ts), with stock-specific validation in [stock-app.schema.ts](config/src/schemas/stock-app.schema.ts). HTTP authentication/session behavior is in the shared [security module](../../libs/core/di/src/http/security.ts). Keep backend credentials out of frontend build variables.
|
||||
|
||||
## Supported execution
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
# API Configuration
|
||||
VITE_API_BASE_URL=http://localhost:2003
|
||||
VITE_DATA_SERVICE_URL=http://localhost:3001
|
||||
VITE_PORTFOLIO_SERVICE_URL=http://localhost:3002
|
||||
VITE_STRATEGY_SERVICE_URL=http://localhost:3003
|
||||
VITE_EXECUTION_SERVICE_URL=http://localhost:3004
|
||||
|
||||
# Environment
|
||||
# API Configuration
|
||||
VITE_API_BASE_URL=
|
||||
VITE_DATA_SERVICE_URL=http://localhost:3001
|
||||
VITE_PORTFOLIO_SERVICE_URL=http://localhost:3002
|
||||
VITE_STRATEGY_SERVICE_URL=http://localhost:3003
|
||||
VITE_EXECUTION_SERVICE_URL=http://localhost:3004
|
||||
|
||||
# Environment
|
||||
VITE_NODE_ENV=development
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# API Configuration
|
||||
# Web API service URL (default port: 2003)
|
||||
VITE_API_BASE_URL=http://localhost:2003
|
||||
# Leave blank to use this browser's hostname on port 2003 in development.
|
||||
# Set an explicit URL only when the API is hosted elsewhere.
|
||||
VITE_API_BASE_URL=
|
||||
|
||||
# Other services (if needed in the future)
|
||||
VITE_DATA_SERVICE_URL=http://localhost:3001
|
||||
|
|
@ -9,4 +10,4 @@ VITE_STRATEGY_SERVICE_URL=http://localhost:3003
|
|||
VITE_EXECUTION_SERVICE_URL=http://localhost:3004
|
||||
|
||||
# Environment
|
||||
VITE_NODE_ENV=development
|
||||
VITE_NODE_ENV=development
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ bun run type-check
|
|||
|
||||
These start Vite development, build static assets, preview a build, and check frontend types respectively; run the command you need. React, TypeScript, Vite, Tailwind, Headless UI and Recharts are the main UI dependencies. See [package.json](package.json) for scripts and pinned ranges.
|
||||
|
||||
Vite is configured for `127.0.0.1:3000`. The API origin is `VITE_API_BASE_URL` when supplied; otherwise development uses the browser's hostname on port `2003`, and production uses the page's own origin. The dev server has no configured API proxy. The backend must be running and allow the frontend origin for authenticated cross-origin requests.
|
||||
Vite is configured for `127.0.0.1:5173`, with a fixed port so it cannot silently move to an origin the API does not allow. Port `3000` belongs to Grafana in the Docker stack. Open `http://localhost:5173` or `http://127.0.0.1:5173`. The API origin is `VITE_API_BASE_URL` when supplied; the checked-in value is blank, so development follows the browser's hostname on port `2003`, and production uses the page's own origin. This keeps the session cookie on the same hostname: mixing `127.0.0.1` and `localhost` can prevent sign-in from persisting. Restart Vite after changing environment configuration. The dev server has no configured API proxy. The backend must be running and allow the frontend origin for authenticated cross-origin requests.
|
||||
|
||||
Browser authentication uses HttpOnly session cookies. `VITE_API_BASE_URL` is a public address, not a place for service credentials. Research runs also need the orchestrator and its configured infrastructure; starting Vite alone supplies the interface only.
|
||||
|
||||
|
|
|
|||
|
|
@ -2,15 +2,16 @@ import { browserLog } from '@/utils/browserLog';
|
|||
|
||||
// Global error handler for chart disposal errors
|
||||
export function setupChartErrorHandler() {
|
||||
// Only suppress chart disposal errors during page unload
|
||||
// pagehide works with back/forward caching and documents that disallow unload.
|
||||
// Restore normal reporting if the browser later restores this same document.
|
||||
let isUnloading = false;
|
||||
|
||||
window.addEventListener('beforeunload', () => {
|
||||
window.addEventListener('pagehide', () => {
|
||||
isUnloading = true;
|
||||
});
|
||||
|
||||
window.addEventListener('unload', () => {
|
||||
isUnloading = true;
|
||||
window.addEventListener('pageshow', () => {
|
||||
isUnloading = false;
|
||||
});
|
||||
|
||||
// Intercept console errors for chart disposal
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ export default defineConfig({
|
|||
},
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
port: 5173,
|
||||
strictPort: true,
|
||||
host: '127.0.0.1',
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue