Google sees 404s from my SPA (served through not_found_handling)
I have a Worker with a single page app serving on routes not matched by the worker code.
The SPA loads just fine in my browser, but if I make a cURL request I get a 404.
For example
curl https://www.togethertime.games/games/chess gives a 404, but https://www.togethertime.games/games/chess works just fine.
This is affecting the Google Bot, too. Any suggestions on how to resolve?10 Replies
It's from a decision the Workers Static Assets team made to make it sort of quickly work but is a bit bleh. Leo outlined the header you see, and browsers send that header automagically
ah thanks, that at least helps me to understand the behavior!
For now, you should have your Worker call the not found logic when it doesn't find anything either/run
what would my not found logic in the Worker do?
call
return env.ASSETS.fetch(request); at the end, if your worker script didn't find anything to run
like for example, ah gotcha, that's helpful thank you!
that'll invoke the not found behavior even without the header if nothing in the worker runs
yea, this is def a bit messy right now, hoping the team just launches proper _routes.json like Pages had where you can configure exactly where your worker runs, and gets away from this current behavior
do I need to add a binding to my assets? They don't appear in my
worker-configuration.d.ts automaticallyif you don't have it configured already yea, ex:
or for wrangler json
https://developers.cloudflare.com/workers/static-assets/
I assume you have the directory/etc already set, just need to add the binding name
this is the asset in my wrangler.json:
but it gets processed by the cloudflare/vite-plugin and generates a new wrangler file for the actual deploy i think
that's perfect, looks like it solved it!
i appreciate the quick help 😄