Bones
Bones
CDCloudflare Developers
Created by Bones on 1/27/2025 in #general-help
I replaced `adapter-cloudflare-workers` with `adapter-cloudflare`, it works fine, i am going crazy
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 😄
3 replies
CDCloudflare Developers
Created by Bones on 1/27/2025 in #general-help
I replaced `adapter-cloudflare-workers` with `adapter-cloudflare`, it works fine, i am going crazy
But going through the CF Docs i came across the following bit:
Use Workers Static Assets Instead

You should use [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/) to host full-stack applications instead of Workers Sites. Do not use Workers Sites for new projects.
Use Workers Static Assets Instead

You should use [Workers Static Assets](https://developers.cloudflare.com/workers/static-assets/) to host full-stack applications instead of Workers Sites. Do not use Workers Sites for new projects.
naturally, i replaced the following part of my wrangler.json:
"site": {
"bucket": ".svelte-kit/cloudflare",
"include": [
"*"
],
"exclude": [
"*.map"
]
},
"site": {
"bucket": ".svelte-kit/cloudflare",
"include": [
"*"
],
"exclude": [
"*.map"
]
},
with this:
"assets": {
"directory": ".svelte-kit/cloudflare"
},
"assets": {
"directory": ".svelte-kit/cloudflare"
},
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:
> Using @sveltejs/adapter-cloudflare-workers
error during build:
Error: You must specify site.bucket in wrangler.json. Consult https://developers.cloudflare.com/workers/platform/sites/con
figuration
> Using @sveltejs/adapter-cloudflare-workers
error during build:
Error: You must specify site.bucket in wrangler.json. Consult https://developers.cloudflare.com/workers/platform/sites/con
figuration
I turned to the almighty ChatGPT which suggested replacing adapter-cloudflare-workers with adapter-cloudflare in the svelte.config.js file, i did that:
import adapter from '@sveltejs/adapter-cloudflare';
import { mdsvex } from 'mdsvex';
import rehypeSlug from 'rehype-slug';

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter()
},
preprocess: mdsvex({
extensions: ['.svx', '.md'],
rehypePlugins: [rehypeSlug]
}),
extensions: ['.svelte', '.svx', '.md']
};

export default config;
import adapter from '@sveltejs/adapter-cloudflare';
import { mdsvex } from 'mdsvex';
import rehypeSlug from 'rehype-slug';

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter()
},
preprocess: mdsvex({
extensions: ['.svx', '.md'],
rehypePlugins: [rehypeSlug]
}),
extensions: ['.svelte', '.svx', '.md']
};

export default config;
and to my surprise, it worked! npm run preview and npm run deploy ran successfully and everything works in the deployed website.
3 replies