question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Middleware edge functions do not support POST request with "Expect: 100-continue" HTTP header

See original GitHub issue

Steps to reproduce:

  1. Add any valid _middleware.ts to a NextJS application.
  2. Deploy to Vercel
  3. Make a POST request to any url where that middleware will be run with: Expect: 100-continue as an HTTP header, and any non-empty body content.

Result:

We get a 502 Bad Gateway with the following response body:

An internal error occurred with Vercel.

INTERNAL_EDGE_FUNCTION_CONNECTION_CLOSED

In the function log, we get a message that the middleware was called, but the code does not execute (adding a console.info in the middleware does not show up in the function log)

Expected result:

Middleware and page or api executes appropriately.

Expect: 100-continue is part of the HTTP 1.1 spec and should be implemented, or should be documented explicitly as not implemented.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:29 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
littleStudentcommented, Sep 9, 2022

👋 We are having the same issue since 12hours ago as well. Seems like POST requests from some locations (confirmed via VPN for the UK) run into a 502 - INTERNAL_EDGE_FUNCTION_CONNECTION_CLOSED

From other parts of the world we do not see such a problem

0reactions
viekocommented, Nov 4, 2022

We brought back the middleware, working as expected. There was an issue on Vercel’s end which has been fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Next.js' middleware and Edge Functions
Middleware is a Next.js feature that solves basic problems like authentication and geolocation with the help of Vercel Edge Functions.
Read more >
Proper Node.js API for determining whether or not `100 ...
This seems to work: server.on('checkContinue', (req, res) => { res.mySent100 = true; res.writeContinue(); server.emit('request', req, ...
Read more >
'Expect: 100-Continue' Issues and Risks
API POST requests sent using HTTP clients and with an Expect: 100-Continue request header are significantly more likely to fail that...
Read more >
Request draining with ASP.NET Core Kestrel web server
The app doesn't always consume the request body, such as HTTP POST ... better for clients to use the Expect: 100-continue request header...
Read more >
Restrictions on edge functions - Amazon CloudFront
The following HTTP headers are not exposed to edge functions, and functions can't add them. If your function adds one of these headers,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found