chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.68k stars 826 forks source link

Add documentation for http proxy middleware in API Routes Nextjs #863

Closed phatify closed 4 months ago

phatify commented 1 year ago

Describe the feature you'd love to see

Add documentation for http proxy middleware in API Routes Nextjs

Additional context (optional)

No response

justin-together commented 1 year ago

I've found the examples provided elsewhere don't work correctly on the first request. The first request triggers .on('upgrade') registration, causing subsequent requests to succeed. But the first request hangs indefinitely.

chimurai commented 1 year ago

@justin-together could you give concrete urls to the examples you are referring to?

Here you can find a Next.js recipe: https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/servers.md#nextjs

Documentation to subscribe to upgrade event manually: https://github.com/chimurai/http-proxy-middleware/blob/master/README.md#external-websocket-upgrade

Happy to hear what kind of document is missing and can be improved