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

feat: support nextjs v12 #35

Merged
merged 1 commit into from
Mar 28, 2022

Conversation

kirill-kruchkov
Copy link
Contributor

@kirill-kruchkov kirill-kruchkov commented Feb 21, 2022

NextJS v12 requires a hostname and port to be provided for the custom server when a middleware is used in the project (https://nextjs.org/docs/advanced-features/custom-server). Updating NextJS breaks such a project's dev server, if it uses next-remote-watch@1.0.0. Here's an example:

image

This PR updates NextJS as a devDependency (not a peerDependency) of next-remote-watch and addresses the aforementioned issue by:

  1. Reading a HOSTNAME alongside the PORT from env variables.
  2. Supplying a default value for the hostname (localhost).
  3. Providing both in the next(...) options.

It also adds a middleware to test this behaviour.

@hashicorp-cla
Copy link

hashicorp-cla commented Feb 21, 2022

CLA assistant check
All committers have signed the CLA.

@BRKalow
Copy link
Contributor

BRKalow commented Mar 7, 2022

Thanks for the contribution! It looks like it will, but just confirming, will this change work fine on older versions of next?

@kirill-kruchkov
Copy link
Contributor Author

Hello @BRKalow! I think it should, but let me test it again in the evening.

@kirill-kruchkov
Copy link
Contributor Author

@BRKalow I created a separate branch that includes this change while using Next v10. I haven't noticed anything unusual, but I'm not familiar well enough with all the test cases (there're 4 test scripts in the package.json). Would be great if someone could double check it: https://github.com/kirill-kruchkov/next-remote-watch/tree/test/next-10.

Also, I realised that this repo uses npm (I used yarn at first), so I updated this PR accordingly (dropped yarn.lock and updated package-lock.json).

@BRKalow BRKalow merged commit 53278da into hashicorp:master Mar 28, 2022
Copy link
Contributor

@BRKalow BRKalow left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

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.

3 participants