Commit graph

7 commits

Author SHA1 Message Date
Balázs Orbán
1ff7f07875
feat: drop Node.js 16 (#56896)
### What?

BREAKING CHANGE: Bump the minimum required Node.js version.

### Why?

Node.js 16 has reached end-of-life in September.

Bumped to `18.18.2` since it contained some security-related patches: https://nodejs.org/en/blog/vulnerability/october-2023-security-releases

### How?

Bumped `engines` where needed, upgraded the workflows.

This will allow us to remove quite a few polyfills, I'll open separate PRs for those.
2023-10-16 21:41:38 +00:00
JJ Kasper
1149cccd94
Add client router filter handling (#46283)
This adds a new client router filter for app paths and redirects so that
we correctly hard navigate when a transition for one of this paths is
encountered. This fixes the longstanding issue where redirects weren't
applied on the client so a redirect that matches a dynamic route as well
would transition to the dynamic route on client transition but not on
direct visit. Similarly this ensures we hard navigate to app paths from
pages even if a page dynamic route matches the path.

The specific filter leveraged here is a bloom filter as we can tolerate
some false matches (currently targeting an error rate of `2%`) as they
just trigger a hard navigation which should be acceptable and this also
avoids needing to send an entire manifest with the related paths.

We can leverage a manifest for the generated SSG paths as well in a
follow-up to fix `fallback: false` routes not being navigated correctly
on client-transition in some cases as well.


The filter is initially behind an `experimental.clientRouterFilter` flag
in `next.config.js` although this is auto-enabled when leveraging app
directory to ensure proper transitions.

fixes NEXT-609
closes: https://github.com/vercel/next.js/pull/46235
x-ref: [slack
thread](https://vercel.slack.com/archives/C035J346QQL/p1677028663246719)

x-ref: https://github.com/vercel/next.js/issues/41344
x-ref: https://github.com/vercel/next.js/issues/40062
x-ref: https://github.com/vercel/next.js/issues/37889
x-ref: https://github.com/vercel/next.js/discussions/26426
x-ref: https://github.com/vercel/next.js/issues/35837

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2023-02-22 22:02:31 -08:00
Tim Neutkens
efcec4c1e3
Move core files to src folder and move JS files to TypeScript (#44405) 2023-01-03 10:05:50 +01:00
Damien Simonin Feugas
35f1a3501a
feat: enables 'edge' as a possible runtime for API routes (#44045) 2022-12-15 10:08:03 +01:00
Gal Schlezinger
41d4aa04c4
allow Edge Functions to stream a compressed fetch response (#39608)
When a user tried to have the following Edge Function:

```ts
export default () => fetch("https://example.vercel.sh");
```

The Edge Function were failing.

Why is that?

When `fetch` was called, an implicit `Accept-Encoding` header was added
to allow the origin to return a compressed response. Then, the origin
will set the `Content-Encoding` header in the response, to let the
client know that the body needs to be decompressed in order to be read.

That creates an issue though: `response.body` will be a
`ReadableStream<Uint8Array>`, or, a stream that contains binary data
that decodes into _the uncompressed data_ (or, plain text!).

What it means, is that `response.body` is uncompressed data, while
`response.headers.get('content-encoding')` is marking the response body
as compressed payload. This confuses the HTTP clients and makes them fail.

This commit removes the `content-encoding`, `transfer-encoding` and
`content-length` headers from the response, as the Next.js server _always_
streams Edge Function responses.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-08-21 10:43:02 +00:00
JJ Kasper
8fe44c3102
Update edge blob asset e2e test (#38857) 2022-07-20 18:52:26 -05:00
Gal Schlezinger
20486c159d
[edge] allow importing blob assets (#38492)
* [edge] allow importing blob assets

* Fix test

* extract to a new file, to make it easier to read and review

* Use webpack asset discovery and transform with a loader

* fix tests

* don't prefix assets

* use emitFile

* rename assets to blobs to be more specific

* rename blobs to assets and use webpack's hashing algo

* Dedupe correctly

* Add a Node.js dep test

* Update packages/next/server/next-server.ts

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>

* [code review] test remote URL fetches

* [code review] use `import type` for type-only imports

* Update packages/next/server/next-server.ts

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-07-19 12:27:15 -05:00