Skip to content

Commit dfe906d

Browse files
Copilotdaesdev
andauthored
fix: resolve Cloudflare Workers deployment failure caused by unbundleable Deno/Fresh imports
Agent-Logs-Url: https://github.com/daesdev/vibe-coding/sessions/b78c3f96-eb8f-4fe4-ae01-4425291f58ce Co-authored-by: daesdev <31475869+daesdev@users.noreply.github.com>
1 parent 78b86fb commit dfe906d

4 files changed

Lines changed: 32 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,28 @@ jobs:
2828
- name: Build step
2929
run: deno task build
3030

31+
- name: Pre-render pages and assemble dist
32+
run: |
33+
set -e
34+
mkdir -p dist
35+
cp -r static/. dist/
36+
cp -r _fresh dist/
37+
deno run -A main.ts &
38+
SERVER_PID=$!
39+
trap 'kill $SERVER_PID 2>/dev/null || true' EXIT
40+
timeout 20 bash -c 'until curl -sf http://localhost:8000/ > /dev/null 2>&1; do sleep 1; done'
41+
mkdir -p dist/es dist/en
42+
curl -sf http://localhost:8000/ -o dist/index.html
43+
curl -sf http://localhost:8000/es -o dist/es/index.html
44+
curl -sf http://localhost:8000/en -o dist/en/index.html
45+
3146
- name: Upload build artifacts
3247
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
3348
uses: actions/upload-artifact@v4
3449
with:
3550
name: fresh-build
3651
path: |
37-
_fresh/
52+
dist/
3853
retention-days: 1
3954

4055
deploy:
@@ -54,7 +69,7 @@ jobs:
5469
uses: actions/download-artifact@v4
5570
with:
5671
name: fresh-build
57-
path: _fresh/
72+
path: dist/
5873

5974
- name: Deploy to Cloudflare Workers
6075
uses: cloudflare/wrangler-action@v3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@
77

88
# Fresh build directory
99
_fresh/
10+
# Pre-rendered static output
11+
dist/
1012
# npm dependencies
1113
node_modules/

server.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Cloudflare Workers entry point for the vibe-coding landing page.
2+
// The Fresh project is pre-rendered to static HTML during CI build (see deploy.yml).
3+
// All requests are served from the pre-rendered dist/ directory via the ASSETS binding.
4+
export default {
5+
async fetch(request, env) {
6+
if (!env.ASSETS) {
7+
return new Response("Asset binding not configured", { status: 500 });
8+
}
9+
return env.ASSETS.fetch(request);
10+
},
11+
};

wrangler.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "vibe-coding",
3-
"main": "./server.ts",
3+
"main": "./server.js",
44
"compatibility_date": "2026-03-29",
55
"assets": {
66
"binding": "ASSETS",
7-
"directory": "./static"
7+
"directory": "./dist"
88
},
99
"routes": [
1010
{

0 commit comments

Comments
 (0)