Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

BlankParticle
Copy link

@BlankParticle BlankParticle commented Sep 9, 2025

Fixes #9567

When using the base config with vite, vite dev server strips out the base part from the url
this means the worker receives a url with /api/test in production but /test in vite dev

we already has to fix this behaviour when working with /cdn-cgi urls for triggers and restore the originalUrl
so this PR actually restores that URL for all requests that are passed into miniflare


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Not needed
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: vite-plugin

@BlankParticle BlankParticle requested review from a team as code owners September 9, 2025 17:28
Copy link

changeset-bot bot commented Sep 9, 2025

🦋 Changeset detected

Latest commit: 5ee7f1d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vite-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@BlankParticle BlankParticle force-pushed the fix/restore-original-url branch 2 times, most recently from 928f0bb to bca6784 Compare September 12, 2025 05:15
@jamesopstad jamesopstad added the vite-plugin Relating to the `@cloudflare/vite-plugin` package label Sep 15, 2025
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Sep 15, 2025
@jamesopstad jamesopstad moved this from Untriaged to In Review in workers-sdk Sep 15, 2025
Copy link

pkg-pr-new bot commented Sep 15, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10593

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10593

miniflare

npm i https://pkg.pr.new/miniflare@10593

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10593

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10593

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10593

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10593

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10593

wrangler

npm i https://pkg.pr.new/wrangler@10593

commit: 5ee7f1d

@jamesopstad
Copy link
Contributor

Hi @BlankParticle. Thanks for the PR. The base option still won't work correctly for Workers with assets (see #9567 (comment)) but it's worth getting this fix in anyway.

Please could you add a test in playground/worker that uses a different Vite config with the base option e.g. vite.config.base. You can see playground/assets for examples of tests using different config files. Thanks.

@BlankParticle
Copy link
Author

I wasn't aware this was a problem with assets too, but yeah we can probably figure out something for that
maybe changing the client output will help, like this /api -> dist/client/api
but thats a separate issue

I will add the tests for now

@BlankParticle BlankParticle force-pushed the fix/restore-original-url branch from bca6784 to 8f411d7 Compare September 16, 2025 05:19
@BlankParticle BlankParticle force-pushed the fix/restore-original-url branch from 8f411d7 to 2a4ded0 Compare September 16, 2025 05:20
@BlankParticle BlankParticle force-pushed the fix/restore-original-url branch from 2a4ded0 to 58b7eff Compare September 16, 2025 05:21
Copy link
Contributor

@jamesopstad jamesopstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the PR!

@github-project-automation github-project-automation bot moved this from In Review to Approved in workers-sdk Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vite-plugin Relating to the `@cloudflare/vite-plugin` package
Projects
Status: Approved
Development

Successfully merging this pull request may close these issues.

Request url received by worker is incorrect when using vite plugin + base option
2 participants