Use STORYKIT_PORT for both backend and frontend, add .story_kit_port to ignore files
Single env var STORYKIT_PORT configures backend port, frontend proxy target, frontend dev server port (port + 2172), and WebSocket host. Added .story_kit_port to .gitignore and .ignore to prevent git tracking and cargo watch restart loops. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
# App specific
|
# App specific
|
||||||
store.json
|
store.json
|
||||||
|
.story_kit_port
|
||||||
|
|
||||||
# Rust stuff
|
# Rust stuff
|
||||||
target
|
target
|
||||||
|
|||||||
1
.ignore
1
.ignore
@@ -4,3 +4,4 @@ node_modules/
|
|||||||
.claude/
|
.claude/
|
||||||
.story_kit/
|
.story_kit/
|
||||||
store.json
|
store.json
|
||||||
|
.story_kit_port
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ export interface CommandOutput {
|
|||||||
exit_code: number;
|
exit_code: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare const __STORYKIT_PORT__: string;
|
||||||
|
|
||||||
const DEFAULT_API_BASE = "/api";
|
const DEFAULT_API_BASE = "/api";
|
||||||
const DEFAULT_WS_PATH = "/ws";
|
const DEFAULT_WS_PATH = "/ws";
|
||||||
|
|
||||||
@@ -235,7 +237,7 @@ export class ChatWebSocket {
|
|||||||
const protocol = window.location.protocol === "https:" ? "wss" : "ws";
|
const protocol = window.location.protocol === "https:" ? "wss" : "ws";
|
||||||
const wsHost = resolveWsHost(
|
const wsHost = resolveWsHost(
|
||||||
import.meta.env.DEV,
|
import.meta.env.DEV,
|
||||||
import.meta.env.VITE_STORYKIT_PORT,
|
typeof __STORYKIT_PORT__ !== "undefined" ? __STORYKIT_PORT__ : undefined,
|
||||||
window.location.host,
|
window.location.host,
|
||||||
);
|
);
|
||||||
const wsUrl = `${protocol}://${wsHost}${wsPath}`;
|
const wsUrl = `${protocol}://${wsHost}${wsPath}`;
|
||||||
|
|||||||
@@ -3,14 +3,17 @@ import { defineConfig } from "vite";
|
|||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig(() => {
|
export default defineConfig(() => {
|
||||||
const backendPort = process.env.VITE_STORYKIT_PORT || "3001";
|
const backendPort = Number(process.env.STORYKIT_PORT || "3001");
|
||||||
return {
|
return {
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
|
define: {
|
||||||
|
__STORYKIT_PORT__: JSON.stringify(String(backendPort)),
|
||||||
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 5173,
|
port: backendPort + 2172,
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api": {
|
"/api": {
|
||||||
target: `http://127.0.0.1:${backendPort}`,
|
target: `http://127.0.0.1:${String(backendPort)}`,
|
||||||
timeout: 120000,
|
timeout: 120000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user