-
Notifications
You must be signed in to change notification settings - Fork 985
Labels
bugSomething that isn't workingSomething that isn't workingvite-pluginRelating to the `@cloudflare/vite-plugin` packageRelating to the `@cloudflare/vite-plugin` package
Description
What versions & operating system are you using?
vite: 6.3.5, wrangler: 4.19.2, @cloudflare/vite-plugin: ^1.5.1,
Please provide a link to a minimal reproduction
https://github.com/cloudkite/vite-plugin-test
Describe the Bug
When specifying the base option:
// vite.config.ts
import { cloudflare } from "@cloudflare/vite-plugin";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
export default defineConfig({
base: "/subpath",
plugins: [react(), cloudflare()],
});
// worker.ts
export default {
fetch(request: Request) {
console.log(request.url);
return new Response(null, { status: 200 });
},
};
// main.tsx
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
function App() {
return (
<button
type="button"
onClick={() => {
fetch("/subpath/api/")
}}
>
Click me
</button>
);
}
createRoot(document.getElementById("root")).render(
<StrictMode>
<App />
</StrictMode>,
);
When the button is clicked and fetch("/subpath/api/")
is invoked, the base seems to be stripped from the URL. The worker console.log prints:
http://localhost/api
I would expect the worker to receive the full url http://localhost/subpath/api
Metadata
Metadata
Assignees
Labels
bugSomething that isn't workingSomething that isn't workingvite-pluginRelating to the `@cloudflare/vite-plugin` packageRelating to the `@cloudflare/vite-plugin` package
Type
Projects
Status
Backlog