-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
Hi! I'm trying to setup a Hono/Vite project for Cloudflare Pages including support for Durable Objects. However in this setup I noticed that the DO should actually be running as a separate Worker, and referenced using the script_name configuration in the wrangler.toml (similar to #190).
However when running this, I'm receiving the following error:
Cannot access 'MyDurableObject#set' as Durable Object RPC is not yet supported between multiple 'wrangler dev' sessions.
My wrangler.toml looks like the following:
name = "api"
main = "src/api/index.ts"
compatibility_date = "2024-11-29"
compatibility_flags = [ "nodejs_compat_v2" ]
[[durable_objects.bindings]]
name = "MY_DURABLE_OBJECT"
class_name = "MyDurableObject"
script_name = "my-do"
And my vite.config.ts:
import build from '@hono/vite-cloudflare-pages';
import devServer from '@hono/vite-dev-server';
import adapter from '@hono/vite-dev-server/cloudflare';
import { TanStackRouterVite } from '@tanstack/router-plugin/vite';
import viteReact from '@vitejs/plugin-react';
import path from 'path';
import { defineConfig } from 'vite';
const resolve = {
alias: {
'@': path.resolve(__dirname, './src'),
},
};
export default defineConfig(async ({ mode }) => {
if (mode === 'client') {
return {
plugins: [
viteReact(),
TanStackRouterVite({
routesDirectory: 'src/routes',
generatedRouteTree: 'src/routeTree.gen.ts',
}),
],
resolve,
server: {
port: 3000,
proxy: {
'/api': {
target: 'http://localhost:9000',
changeOrigin: true,
rewrite: (path: string) => path.replace(/^\/api/, ''),
},
},
},
};
}
return {
plugins: [
devServer({
entry: 'src/api/index.ts',
adapter,
}),
build(),
],
resolve,
server: {
port: 9000,
},
};
});
Do I have an oversight and/or misconfiguration or should this configuration work?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels