T
T
TchernyavskyDaniil2019-01-14 10:11:11
Node.js
TchernyavskyDaniil, 2019-01-14 10:11:11

Why is EPIPE Koa js thrown out when redirecting?

Good afternoon, you need to make a redirect for SSR to Koa.js.
Conditions for a redirect, if the user went to the main page from a qver, for example, site.ru/?test, then there will be a redirect to the main site.ru.
Everything works fine on the locale, but on the test it crashes with an error:
d2be79e5b383.png
Component code:
https://pastebin.com/3SHxjWR2
The redirect is done from lines 29-32. I check if there is a queristring, if there is, then I redirect to the main one.
d2be79e5b383.png
According to this log from the test, then it enters the condition (mk 2 log console)
Please tell me where to dig? I do not quite understand the essence of the epipe error

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TchernyavskyDaniil, 2019-01-14
@TchernyavskyDaniil

So, added return and everything worked on the test

console.log(ctx.request.query, ctx.request.querystring);
  if (ctx.request.querystring && ctx.request.querystring !== 'auth-need') {
    console.log(ctx.request.query, ctx.request.querystring);
    ctx.redirect('/');
     return;
  }

But can someone explain to me why it helped?
I myself don’t see it yet, but the code after the redirect must be excluded, it sent the headers and then you can’t send anything

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question