Skip to content

Commit 7f0069e

Browse files
NUCLEAR OPTION: Start script with env vars to bypass host check
1 parent c5738f2 commit 7f0069e

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ RUN npm ci
1414
# Copy source code
1515
COPY . .
1616

17+
# Make start script executable
18+
RUN chmod +x start.sh
19+
1720
# Set environment variables to bypass host checking
21+
ENV VITE_ALLOWED_HOSTS=all
1822
ENV VITE_HOST=true
1923
ENV VITE_ALLOWED_HOSTS=all
2024
ENV NODE_ENV=production
@@ -29,6 +33,6 @@ RUN npm run build
2933
# Expose port 8080
3034
EXPOSE 8080
3135

32-
# Use custom preview script for production
33-
CMD ["npm", "run", "preview-prod"]
36+
# Use the start script instead
37+
CMD ["./start.sh"]
3438

astro.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export default defineConfig({
1414
site,
1515
vite: {
1616
server: {
17-
allowedHosts: ['gdg-docs-426637717447.us-central1.run.app'],
17+
allowedHosts: true,
1818
},
1919
preview: {
20-
allowedHosts: ['gdg-docs-426637717447.us-central1.run.app'],
20+
allowedHosts: true,
2121
}
2222
},
2323
integrations: [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"start": "astro dev",
88
"build": "astro build",
99
"preview": "astro preview",
10-
"preview-prod": "astro preview --host 0.0.0.0 --port 8080",
10+
"preview-prod": "astro preview --host 0.0.0.0 --port 8080 --allowed-hosts gdg-docs-426637717447.us-central1.run.app",
1111
"astro": "astro"
1212
},
1313
"dependencies": {

start.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/bin/sh
2-
# Start script for the container
2+
# Start script for the container with host bypass
33

4-
# Use PORT environment variable if set, otherwise default to 8080
5-
PORT=${PORT:-8080}
4+
# Set environment variables to bypass host checking
5+
export VITE_ALLOWED_HOSTS=all
6+
export ASTRO_TELEMETRY_DISABLED=1
7+
export HOST=0.0.0.0
8+
export PORT=8080
69

7-
echo "Starting server on port $PORT"
8-
# Use astro preview instead of serve for better routing
9-
npx astro preview --port $PORT --host 0.0.0.0
10+
echo "Starting Astro preview server with ALL hosts allowed..."
11+
echo "VITE_ALLOWED_HOSTS=$VITE_ALLOWED_HOSTS"
12+
echo "HOST=$HOST"
13+
echo "PORT=$PORT"
14+
15+
# Use astro preview with explicit allowed hosts bypass
16+
exec npx astro preview --host 0.0.0.0 --port 8080

vite.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { defineConfig } from 'vite';
22

33
export default defineConfig({
44
server: {
5-
allowedHosts: ['gdg-docs-426637717447.us-central1.run.app'],
5+
allowedHosts: 'all',
66
},
77
preview: {
8-
allowedHosts: ['gdg-docs-426637717447.us-central1.run.app'],
8+
allowedHosts: 'all',
99
},
1010
});

0 commit comments

Comments
 (0)