Skip to content
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

Replace append with set in adjustRequestForVercel (Fixes #507) #508

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

rphsoftware
Copy link
Contributor

@rphsoftware rphsoftware commented Oct 16, 2023

This pull request aims to fix the small incompatibility between real Vercel and the simulated Vercel headers by replacing headers, instead of appending to their values. This should fix #507

@changeset-bot
Copy link

changeset-bot bot commented Oct 16, 2023

🦋 Changeset detected

Latest commit: 50ecd26

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

This PR includes changesets to release 2 packages
Name Type
@cloudflare/next-on-pages Patch
eslint-plugin-next-on-pages 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
Contributor

@james-elicx james-elicx left a comment

Choose a reason for hiding this comment

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

Hi there, thank you very much for raising this PR 🙂

Would it be possible for you to add a small patch changeset to it using npx changeset, briefly outlining what this PR fixes?

@rphsoftware
Copy link
Contributor Author

rphsoftware commented Oct 16, 2023

Hi there, thank you very much for raising this PR 🙂

Would it be possible for you to add a small patch changeset to it using npx changeset, briefly outlining what this PR fixes?

I have added a changeset, thanks for the heads-up 😃
Though I am not sure why the changeset bot detects changes to both packages? I only created a changeset for one package

@james-elicx
Copy link
Contributor

I have added a changeset, thanks for the heads-up 😃 Though I am not sure why the changeset bot detects changes to both packages? I only created a changeset for one package

It's because they're fixed to each other, so it releases them both for every version change in each of the two packages. It's so that the version of the eslint package that people use is tied to their version of next-on-pages, instead of them needing to have different version numbers for each one. Makes things simpler to manage.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2023

🧪 Prereleases are available for testing 🧪

@cloudflare/next-on-pages

You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/6539644090/npm-package-next-on-pages-508

@cloudflare/eslint-plugin-next-on-pages

You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/6539644090/npm-package-eslint-plugin-next-on-pages-508

@rphsoftware
Copy link
Contributor Author

rphsoftware commented Oct 16, 2023

@james-elicx Could you tell me/point me towards docs on how to deploy a build of a page made with the preview build of next-on-pages so I can validate that the fix has worked?
I have already ran npx @cloudflare/next-on-pages locally, but I am not sure how to manually upload the newly built site to pages.

@james-elicx
Copy link
Contributor

james-elicx commented Oct 16, 2023

@james-elicx Could you tell me/point me towards docs on how to deploy a build of a page made with the preview build of next-on-pages so I can validate that the fix has worked? I have already ran npx @cloudflare/next-on-pages locally, but I am not sure how to manually upload the newly built site to pages.

Sure thing :). You can deploy a build using Wrangler, and it will prompt you to sign in with your Cloudflare account if you haven't already.

npx wrangler pages deploy .vercel/output/static

You can choose an existing or a new project when deploying. If you are deploying a new project, in the Cloudflare Pages dashboard, you need to ensure that you add the nodejs_compat compatibility flag in your pages project settings after the project has been created. After adding the compatibility flag, you must re-deploy for it to take effect.

Alternatively, if you have a project that is using the Pages Git Integration / CI that you would like to deploy with a prerelease, you could replace the build command with npx https://....., or you could replace the dependency version in package.json with the URL (if you do the latter, you need to make sure your build command is just npx @cloudflare/next-on-pages instead of npx @cloudflare/next-on-pages@1.

@rphsoftware
Copy link
Contributor Author

Alright, I have made a deployment with wrangler, and tested it out. With this patch, the headers are now inline with Vercel.
You can test this for yourself with curl -H "x-vercel-ip-city: Atlantis" https://header-accuracy-test.pages.dev/getheader | jq '.h["x-vercel-ip-city"]'
I will run Prettier and then I think this should be ready.

Copy link
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

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

Thanks a lot @rphsoftware 😃 ❤️

@dario-piotrowicz dario-piotrowicz merged commit ab83858 into cloudflare:main Oct 17, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: Compat: Header values for x-vercel-ip-* headers are appended instead of replaced.
3 participants