Server Side Redirect Returns ERR_HTTP_HEADERS_SENT #15310
Replies: 3 comments 2 replies
-
This code does not work as well:
and to make sure that
|
Beta Was this translation helpful? Give feedback.
-
Can you check if this happens on the |
Beta Was this translation helpful? Give feedback.
-
Seems like this code works:
So, I assume that However, when I use With |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm trying to use a redirect from
getServerSideProps
and I getError [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
in some cases. I have seen that this problem was covered inissues
many times and the solution was to useres.end()
like this.However, the following code fails for me when used with
Link
orRouter.push()
:while this one works:
So, my first guess was that this happens because the first code returns the same props (?) for both paths, but I tried to return
{ props: { foo: 'bar' } };
, and it gave me the same result.It would be super helpful if somebody could help me understand the cause of this behavior.
I've also gone through all links at this RFC
Thanks,
Simon
Beta Was this translation helpful? Give feedback.
All reactions