Commit Graph

13 Commits

Author SHA1 Message Date
Sebastian "Sebbie" Silbermann 6ba71046b0 [test] Move the harness off node-fetch (#98195)
Node.js ships with a built-in `fetch` now so `node-fetch` is no longer
necessary. Mostly motivated by tracing Node.js deprecation warnings
which originated from `node-fetch` by calling the deprecated
`url.parse`.

Call sites keep working through a compatibility type on `fetchViaHTTP`
that translates node-fetch-only options: Instead of `agent` we pass to
`http(s)` directly, `timeout` becomes `AbortSignal.timeout`, and Node.js
readable streams are accepted as bodies with `duplex: 'half'` set
automatically.

The `abort-controller` polyfill is dropped since its signal type
predates the current AbortSignal and undici would not honor it.
`node-fetch` stays installed because `scripts/generate-release-log.mjs`,
`scripts/reset-project.mjs`, and `scripts/update-google-fonts.js` still
import it (follow-up material). Fixture apps will be migrated
separately.
2026-09-10 13:50:35 +02:00
Tim Neutkens e860cec656 test: migrate webdriver callers to next.browser (#93941)
### What?

Migrate remaining direct `next-webdriver` test callers that have a
`NextInstance` to `next.browser()`, and expose the shared `Playwright`
browser type from `e2e-utils`.

### Why?

`NextInstance.browser` should be the supported browser-opening interface
for test fixtures, with `next-webdriver` kept as the private
implementation detail.

### How?

Updated affected development, e2e, and production tests to call
`next.browser()` directly, passing `baseUrl` where tests intentionally
target a manually spawned or proxied server. Shared helpers now receive
browser callbacks from the test context, and browser types import
`Playwright` from `e2e-utils` instead of deriving from `next.browser` or
importing from private paths.

<!-- NEXT_JS_LLM_PR -->
2026-05-22 14:01:58 +02:00
Tim Neutkens 4588a73542 Convert tests using createNext -> nextTestSetup (#93767)
## What?

Converts existing `createNext()` usage into `nextTestSetup()`. 

`createNext()` was the setup step we had before `nextTestSetup()` was
added.

This PR focused on the simple conversion cases. There will be a
follow-up to complete the last few.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 13:16:31 +02:00
Sebastian "Sebbie" Silbermann 93cf074e38 [test] Move off of as much url.parse as possible (#87286)
`url.parse` is deprecated in favor of WHATWG URLs. 

Almost all tests don't actually test integration with `url.parse`.

The remaining places test integration with the Next.js request handler
which does accept `url.parse` values.

We may deprecate that specific signature in favor of accepting WHATWG
URLs instead.
2025-12-26 14:00:28 -07:00
Zack Tanner cdb9a8c3b3 switch development origin verification to be opt-in rather than opt-out (#77395)
To avoid breaking local development proxies and more complex setups,
this ensures that we only block cross-origin development requests when
opting into the configuration. In a future major release, this will not
be opt-in, and will require explicitly providing the allowed origins
that can access the special `/_next` endpoints.

This adds a warning when a cross origin request is detected that would
be blocked without explicit configuration.

Fixes #77073
Fixes #77253
Fixes #77344
2025-03-21 17:08:25 -07:00
JJ Kasper d928709b74 Add handling of origin in dev mode (#76880)
This ensures we don't allow cross-origin requests to be made to `/_next`
resources in dev mode. This matches existing handling that
webpack-dev-middleware does as well.
2025-03-06 22:35:58 +00:00
Tim Neutkens 509c7909c2 Remove legacy next/link prefetch={true} warning (#68326)
## What?

Removes the warning shown in Pages Router when you use the `prefetch`
prop on `next/link`. In App Router using `prefetch={true}` opts in to
full page prefetching even when the route is dynamically rendered.

When you're working on an application that uses both pages router and
app router where the components are shared using `<Link prefetch>` would
then cause this warning in Pages Router but not in App Router.

With this change there won't be a warning in Pages Router.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-07-30 16:36:00 +00:00
Hendrik Liebau 994d8ee2c3 Fix broken BrowserInterface type (#66461) 2024-06-03 12:56:49 +00:00
Sebastian Silbermann ed4d772359 Stop using baseUrl in root tsconfig (#64117) 2024-04-09 00:25:43 +02:00
Hannes Bornö ee0f483159 Migrate basic-basepath tests into basic (#44776)
Removes `test/development/basic-basepath` and migrates those tests into
`test/development/basic` instead. Currently the tests are duplicated but
`/basic-basepath` is just a subset of `/basic`.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
2023-01-11 08:13:19 -08:00
JJ Kasper 19013a5e3f Ensure next.url is used instead of next.appPort (#44163)
`appPort` shouldn't be used unless absolutely necessary as `next.url` is
more specific and allows more control.

x-ref:
https://github.com/vercel/next.js/actions/runs/3734223762/jobs/6336069606
2022-12-19 13:29:50 -08:00
Michiel Van Gendt d7062dddcc Include message body in redirect responses (#31886)
# Description

The redirect responses do not contain a message body. This is in conflict with the RFCs (below) and causes Traefik (a reverse proxy) to invalidate the responses. In this pull request, I add a response body to the redirect responses. 

This PR is similar to https://github.com/vercel/next.js/pull/25257, it appears that there are some other locations where redirection is handled incorrectly in next.js.

# References
- https://datatracker.ietf.org/doc/html/rfc7230#section-3.3

> All 1xx (Informational), 204 (No Content), and 304 (Not Modified) responses must not include a message-body. All other responses do include a message-body, although the body may be of zero length.

- https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.3

> The server's response payload usually contains a short hypertext note with a hyperlink to the different URI(s).

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2021-12-16 05:41:43 +00:00
JJ Kasper a92a5caec2 Update test set-up to leverage playwright when able to (#28634)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-13 14:36:25 +02:00