I replaced `adapter-cloudflare-workers` with `adapter-cloudflare`, it works fine, i am going crazy
I am building a personal blog website with sveltekit and as i am using mdsvex to handle the markdown articles serverside in a
+page.server.js
file, which to my understanding is considered SSR, i went on to use Cloudflare (CF) Workers instead of CF Pages.
This means i ran this command to initialize my svelte project:
as mentioned in the CF Docs and i edited my svelte.config.js
file to look like this:
based on the Svelte Docs and after some trial and error my wrangler.json
file looked like this, and everything worked fine, website deployed successfully etc:
But...1 Reply
But going through the CF Docs i came across the following bit:
naturally, i replaced the following part of my
wrangler.json
:
with this:
as mentioned in the CF Docs. When attempting to run npm run preview
though to test if everything is ok with the worker locally, i got the following error:
I turned to the almighty ChatGPT which suggested replacing adapter-cloudflare-workers
with adapter-cloudflare
in the svelte.config.js
file, i did that:
and to my surprise, it worked! npm run preview
and npm run deploy
ran successfully and everything works in the deployed website.
My questions are:
1. what the hell is going on? 😄
2. am i using cloudflare workers or cloudflare pages right now?
3. on the cloudflare dashboard under Workers & Pages
i see the worker that i initially created, i know it's a worker because:
- it deploys on urls that look like this https://my-svelte-app.mydomainname.workers.dev/
- after i click on the worker i can see in the "Version History" table -> Source column -> it says "wrangler"
- in the package.json
i can see that the npm run preview
and npm run deploy
commands are clearly using wrangler. Wrangler is supposed to be a CF Workers thing, not a CF pages thing right?
If everything points to me using CF Workers, why is adapter-cloudflare
working just fine?
4. Do CF Pages support SSR?
5. Is it possible to make the Workers Static Assets configuration in the wrangler.json
file to somehow work with adapter-cloudflare-workers
without getting the error mentioned above?
6. and finally, should i use adapter-cloudflare-workers
with adapter-cloudflare
and why?
Thanks for reading my wall, i am new to all this so i might have obvious mistakes in my thinking process 😄