I have a code to work properly in Express 3.x and decided to migrate to 4.x. It has mysteriously stopped working, it is not the first application that I migrate and never had had problems, resulting in fact that other applications are more complicated.
This application only takes care of receiving input and redirect to another domain, according to the parameters. But before I assign a header, which instructs the correct customer and also redirects, but it causes an error and quit the program.
# Code
//res.setHeader('X-Robots-Tag' , 'X-Redirect-Tag', data);
res.set('X-Redirect-Tag', data);
res.redirect( destination );
# Error
http.js:690
throw new Error('Can\'t set headers after they are sent.');
^
Error: Can't set headers after they are sent.
at ServerResponse. OutgoingMessage.setHeader (http.js:690:11)
at /Users/Anto/Documents/ workspace/Migrate-Redirect/ routes/tracking.js:332:10
at /Users/Anto/Documents/ workspace/Migrate-Redirect/ routes/tracking.js:327:4
at fn (/Users/Anto/Documents/ workspace/Migrate-Redirect/ node_modules/async/lib/async. js:641:34)
at Object._onImmediate (/Users/Anto/Documents/ workspace/Migrate-Redirect/ node_modules/async/lib/async. js:557:34)
at processImmediate [as _immediateCallback] (timers.js:354:15)
I have reviewed all the code and before this portion, do any sending message, render or redirect. Headers are not set.
I took some time and I can not give with the bug. Thank you.
> I have a code to work properly in Express 3.x and decided to migrate to 4.x. It has mysteriously stopped working, it is not the first application that I migrate and never had had problems, resulting in fact that other applications are more complicated.
>
> This application only takes care of receiving input and redirect to another domain, according to the parameters. But before I assign a header, which instructs the correct customer and also redirects, but it causes an error and quit the program.
>
> # Code
> //res.setHeader('X-Robots-Tag' , 'X-Redirect-Tag', data);
> res.set('X-Redirect-Tag', data);
> res.redirect( destination );
>
> # Error
> http.js:690
> throw new Error('Can\'t set headers after they are sent.');
> ^
> Error: Can't set headers after they are sent.
> at ServerResponse. OutgoingMessage.setHeader (http.js:690:11)
> at /Users/Anto/Documents/ workspace/Migrate-Redirect/ routes/tracking.js:332:10
> at /Users/Anto/Documents/ workspace/Migrate-Redirect/ routes/tracking.js:327:4
> at fn (/Users/Anto/Documents/ workspace/Migrate-Redirect/ node_modules/async/lib/async. js:641:34)
> at Object._onImmediate (/Users/Anto/Documents/ workspace/Migrate-Redirect/ node_modules/async/lib/async. js:557:34)
> at processImmediate [as _immediateCallback] (timers.js:354:15)
>
> I have reviewed all the code and before this portion, do any sending message, render or redirect. Headers are not set.
If you could provide a complete runnable program that demonstrates the problem, it would be easier to suggest a solution.
>
> This application only takes care of receiving input and redirect to another domain, according to the parameters. But before I assign a header, which instructs the correct customer and also redirects, but it causes an error and quit the program.
>
> # Code
> //res.setHeader('X-Robots-Tag'
> res.set('X-Redirect-Tag', data);
> res.redirect( destination );
>
> # Error
> http.js:690
> throw new Error('Can\'t set headers after they are sent.');
> ^
> Error: Can't set headers after they are sent.
> at ServerResponse.
> at /Users/Anto/Documents/
> at /Users/Anto/Documents/
> at fn (/Users/Anto/Documents/
> at Object._onImmediate (/Users/Anto/Documents/
> at processImmediate [as _immediateCallback] (timers.js:354:15)
>
> I have reviewed all the code and before this portion, do any sending message, render or redirect. Headers are not set.
If you could provide a complete runnable program that demonstrates the problem, it would be easier to suggest a solution.
댓글 없음:
댓글 쓰기