mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
bc59f210b0
This PR removes middleware docs and adds a "Migration to Proxy" section to the Proxy docs, which explains the rationale for the renaming to Proxy and provides a migration guide. Did not remove `middleware-upgrade-docs` as it's an upgrade doc from the legacy middleware. Below are untouched as they need codebase changes: - `instrumentation` docs - `onRequestError` has `context.routeType` as `'middleware'` - `adapterPath` docs - has `MiddlewareMatcher` type example - `ProxyConfig` - has a user-facing `MiddlewareMatcher` type --------- Co-authored-by: Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
22 lines
1.0 KiB
Plaintext
22 lines
1.0 KiB
Plaintext
---
|
|
title: Using Node.js Modules in Edge Runtime
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
The code in your [Proxy](/docs/pages/api-reference/file-conventions/proxy) or your [Edge API Routes](/docs/pages/building-your-application/routing/api-routes) is using a feature from Node.js runtime.
|
|
|
|
However, the Edge Runtime does not support [Node.js APIs and globals](/docs/pages/api-reference/edge#unsupported-apis).
|
|
|
|
## Possible Ways to Fix It
|
|
|
|
When running Next.js locally with `next dev`, your application will show in the console, and in your browser, which file is importing and using an unsupported module. This module must be avoided: either by not importing it, or by replacing it with a polyfill.
|
|
|
|
For example, you might replace the Node.js `crypto` module with the [Web Crypto API](https://developer.mozilla.org/docs/Web/API/Web_Crypto_API).
|
|
|
|
## Useful Links
|
|
|
|
- [Edge Runtime Supported APIs](/docs/pages/api-reference/edge)
|
|
- [Next.js Proxy](/docs/pages/api-reference/file-conventions/proxy)
|
|
- [JWT Example](https://vercel.com/templates/next.js/jwt-authentication)
|