Skip to content

Also handle next apps hosted on a subpath #9785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2025
Merged

Conversation

matthewdavidrodgers
Copy link
Contributor

Next apps can be hosted on a subpath, i.e. not at the root, so we need to be a little more permissive with the path we check on.

Fixes #[insert GH or internal issue link(s)].

Describe your change...


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: small patch change
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not a wrangler change

@matthewdavidrodgers matthewdavidrodgers requested a review from a team as a code owner June 27, 2025 23:29
Copy link

changeset-bot bot commented Jun 27, 2025

🦋 Changeset detected

Latest commit: deb55b5

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/workers-shared 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

Copy link

pkg-pr-new bot commented Jun 27, 2025

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

wrangler

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

commit: deb55b5

@@ -272,6 +272,31 @@ describe("unit tests", async () => {
expect(await response.text()).toBe("Blocked");
});

it("blocks /_next/image requests with remote URLs when not fetched as image for next apps host not at the root", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe:

Suggested change
it("blocks /_next/image requests with remote URLs when not fetched as image for next apps host not at the root", async () => {
it("blocks /base/path/_next/image requests with remote URLs when not fetched as image", async () => {

I think using it.each to parametrize the test by path would be nice here to remove duplication.

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Would be nice to use it.each in tests

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jun 28, 2025
Next apps can be hosted on a subpath, i.e. not at the root, so we need
to be a little more permissive with the path we check on.
@vicb vicb added this pull request to the merge queue Jul 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2025
@petebacondarwin petebacondarwin added this pull request to the merge queue Jul 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2025
@petebacondarwin petebacondarwin added this pull request to the merge queue Jul 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 2, 2025
@petebacondarwin petebacondarwin added this pull request to the merge queue Jul 2, 2025
Merged via the queue into main with commit 07416ba Jul 2, 2025
49 of 52 checks passed
@petebacondarwin petebacondarwin deleted the next-base-paths branch July 2, 2025 09:26
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Jul 2, 2025
@workers-devprod workers-devprod mentioned this pull request Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants