Skip to content

Commit c0e3ec8

Browse files
author
Lasim
committed
fix: update environment variable names for frontend and backend URLs in Docker commands and CORS configuration
1 parent 0c27b13 commit c0e3ec8

File tree

3 files changed

+42
-8
lines changed

3 files changed

+42
-8
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ Alternatively, you can deploy the pre-built Docker images for the frontend and b
118118
```bash
119119
docker run -d \
120120
-p 3000:3000 \
121+
-e DEPLOYSTACK_FRONTEND_URL="http://localhost:8080" \
121122
-v $(pwd)/services/backend/persistent_data:/app/persistent_data \
122123
deploystack/backend:latest
123124
```
@@ -128,15 +129,36 @@ Alternatively, you can deploy the pre-built Docker images for the frontend and b
128129

129130
```bash
130131
docker run -d -p 8080:80 \
131-
-e VITE_DEPLOYSTACK_APP_URL="http://localhost:3000" \
132+
-e VITE_DEPLOYSTACK_BACKEND_URL="http://localhost:3000" \
132133
-e VITE_APP_TITLE="DeployStack Instance" \
133134
deploystack/frontend:latest
134135
```
135136

136137
**Note:**
137-
- Ensure the `VITE_DEPLOYSTACK_APP_URL` points to where your backend service is accessible. If running both containers on the same Docker host, `http://localhost:3000` (or the host's IP/hostname if `localhost` doesn't resolve correctly from within the frontend container's network to the backend's exposed port) should work.
138+
- Ensure the `VITE_DEPLOYSTACK_BACKEND_URL` points to where your backend service is accessible. If running both containers on the same Docker host, `http://localhost:3000` (or the host's IP/hostname if `localhost` doesn't resolve correctly from within the frontend container's network to the backend's exposed port) should work.
138139
- The `$(pwd)` in the backend command assumes you are in the root of the `deploystack` project directory. Adjust the path to `services/backend/persistent_data` if running from elsewhere, or use an absolute path or a Docker named volume.
139140

141+
#### Production Deployment
142+
143+
For production deployments on a VPS or remote server, update the environment variables to use your server's IP address:
144+
145+
**Backend:**
146+
```bash
147+
docker run -d \
148+
-p 3000:3000 \
149+
-e DEPLOYSTACK_FRONTEND_URL="http://YOUR_SERVER_IP:8080" \
150+
-v $(pwd)/services/backend/persistent_data:/app/persistent_data \
151+
deploystack/backend:latest
152+
```
153+
154+
**Frontend:**
155+
```bash
156+
docker run -d -p 8080:80 \
157+
-e VITE_DEPLOYSTACK_BACKEND_URL="http://YOUR_SERVER_IP:3000" \
158+
-e VITE_APP_TITLE="DeployStack Instance" \
159+
deploystack/frontend:latest
160+
```
161+
140162
## Project Structure
141163
142164
This repository uses a monorepo structure optimized for MCP server deployment:

services/backend/src/fastify/plugins/index.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@ import fastifyFavicon from 'fastify-favicon'
33
import fastifyCors from '@fastify/cors'
44

55
export const registerFastifyPlugins = async (server: FastifyInstance): Promise<void> => {
6+
// Build allowed origins array
7+
const defaultOrigins = [
8+
'http://localhost:5174', // Vite dev server (actual dev port)
9+
'http://localhost:3000', // Frontend production (if served from same port)
10+
'http://localhost:4173', // Vite preview
11+
];
12+
13+
// Add frontend URL from environment variable
14+
const frontendUrl = process.env.DEPLOYSTACK_FRONTEND_URL;
15+
if (frontendUrl) {
16+
defaultOrigins.push(frontendUrl);
17+
}
18+
619
// Register CORS plugin
720
await server.register(fastifyCors, {
8-
origin: [
9-
'http://localhost:5173', // Vite dev server
10-
'http://localhost:3000', // Frontend production (if served from same port)
11-
'http://localhost:4173', // Vite preview
12-
],
21+
origin: defaultOrigins,
1322
credentials: true,
1423
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS']
1524
})
1625

26+
// Log the allowed origins for debugging
27+
server.log.info(`CORS configured with origins: ${defaultOrigins.join(', ')}`);
28+
1729
// Register favicon plugin
1830
await server.register(fastifyFavicon, {
1931
path: '../shared/public/img',

services/frontend/src/services/database.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class DatabaseService {
66
private storageKey: string;
77

88
constructor() {
9-
this.baseUrl = getEnv('VITE_DEPLOYSTACK_APP_URL') || 'http://localhost:3000';
9+
this.baseUrl = getEnv('VITE_DEPLOYSTACK_BACKEND_URL') || 'http://localhost:3000';
1010
this.storageKey = `deploystack_db_setup_status_${this.baseUrl}`;
1111
}
1212

0 commit comments

Comments
 (0)