I'm looking for a way to replicate worker wrangler.toml/routes in local dev mode

# wrangler.toml
# ...

routes = [
{ pattern = "example.test/api*", zone_name = "example.test" },
{ pattern = "localhost:4321/api*", zone_name = "localhost" },
]
# wrangler.toml
# ...

routes = [
{ pattern = "example.test/api*", zone_name = "example.test" },
{ pattern = "localhost:4321/api*", zone_name = "localhost" },
]
Probably not possible with wrangler only. Maybe it's possible with miniflare, zero trust and/or WARP client?
5 Replies
knoblauchbrot
knoblauchbrot5mo ago
@Varna did you ever figure out how to do this? I joined the Discord specifically because I had this question too.
Varna
Varna5mo ago
Sorry for late reply @knoblauchbrot I did not, but I'm using Vite, so I set up Vite proxy instead. The setup is this: On Production, the normal flow is that my server .use() client bundle to serve client app on same worker. On Development, my front-end (Vite) server uses proxy feature, to serve /api routes on same domain (localhost).
Varna
Varna5mo ago
Varna
Varna5mo ago
export default defineConfig({
server: {
proxy: {
'/api': {
// if api worker running on localhost:4321
target: 'http://localhost:4321/api',
changeOrigin: true
},
},
},
})
export default defineConfig({
server: {
proxy: {
'/api': {
// if api worker running on localhost:4321
target: 'http://localhost:4321/api',
changeOrigin: true
},
},
},
})
I don't remember If I had used any additional properties. atm in countryside
knoblauchbrot
knoblauchbrot5mo ago
No worries @Varna, appreciate you responding at all 👍 Gotcha, thanks. Unfortunately, not an option in my case, but thank you for sharing this, might help someone else 🤝
Want results from more Discord servers?
Add your server