Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/shiny-facts-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"create-cloudflare": patch
---

remove unnecessary ASSETS binding call in SPA templates

With SPA mode now enabled by default for compat dates since 2025-04-01, the Workers in the React and Vue templates no longer need this fallback ASSETS binding.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function App() {
Name from API is: {name}
</button>
<p>
Edit <code>api/index.js</code> to change the name
Edit <code>worker/index.js</code> to change the name
</p>
</div>
<p className='read-the-docs'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export default {
});
}

Comment thread
emily-shen marked this conversation as resolved.
return env.ASSETS.fetch(request);
return new Response(null, { status: 404 });
},
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "<TBD>",
"main": "api/index.js",
"main": "worker/index.js",
"compatibility_date": "<TBD>",
"assets": { "not_found_handling": "single-page-application", "binding": "ASSETS" },
"assets": { "not_found_handling": "single-page-application" },
"observability": {
"enabled": true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function App() {
Name from API is: {name}
</button>
<p>
Edit <code>api/index.ts</code> to change the name
Edit <code>worker/index.ts</code> to change the name
</p>
</div>
<p className='read-the-docs'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.worker.tsbuildinfo",
"types": ["@cloudflare/workers-types/2023-07-01", "./worker-configuration.d.ts", "vite/client"],
},
"include": ["api"],
"include": ["worker"],
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
export default {
fetch(request, env) {
fetch(request) {
const url = new URL(request.url);

if (url.pathname.startsWith("/api/")) {
return Response.json({
name: "Cloudflare",
});
}
Comment thread
emily-shen marked this conversation as resolved.

return env.ASSETS.fetch(request);
return new Response(null, { status: 404 });
},
} satisfies ExportedHandler<Env>;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "<TBD>",
"main": "api/index.ts",
"main": "worker/index.ts",
"compatibility_date": "<TBD>",
"assets": { "not_found_handling": "single-page-application", "binding": "ASSETS" },
"assets": { "not_found_handling": "single-page-application" },
"observability": {
"enabled": true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
fetch(request, env) {
fetch(request) {
const url = new URL(request.url);

if (url.pathname.startsWith("/api/")) {
Expand All @@ -8,6 +8,6 @@ export default {
});
}

Comment thread
emily-shen marked this conversation as resolved.
return env.ASSETS.fetch(request);
return new Response(null, { status: 404 });
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"main": "server/index.ts",
"assets": {
"not_found_handling": "single-page-application",
"binding": "ASSETS"
},
"observability": {
"enabled": true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
export default {
fetch(request, env) {
fetch(request) {
const url = new URL(request.url);

if (url.pathname.startsWith("/api/")) {
return Response.json({
name: "Cloudflare",
});
}
Comment thread
emily-shen marked this conversation as resolved.

return env.ASSETS.fetch(request);
return new Response(null, { status: 404 });
},
} satisfies ExportedHandler<Env>;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"main": "server/index.ts",
"assets": {
"not_found_handling": "single-page-application",
"binding": "ASSETS"
},
"observability": {
"enabled": true
Expand Down