davideast / angular-universal-express-firebase

A packaged Cloud Function to serve Angular Universal apps.
50 stars 9 forks source link

"Can't set headers after they're set" error #10

Open mrjmd opened 6 years ago

mrjmd commented 6 years ago

At this point my Universal app seems to be mostly working when I run it locally using firebase serve --only functions,hosting. I can access localhost:5000 and see my application, and when I turn js off I can see that Universal is rendering the front page server side.

However there are a few issues. Routes do not seem to work at all server side, any route I try just renders the front page of the app. Also when I try to firebase deploy I get an error that doesn't give me much context to go on:

image

Further, if I try to hit the function directly on my local, I get the following errors in the terminal:

Error: Can't set headers after they are sent. at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:357:11) at ServerResponse.header (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/response.js:730:10) at ServerResponse.send (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/response.js:170:12) at ServerResponse.json (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/response.js:256:15) at ProxyServer.Supervisor._proxy.on (/usr/local/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator/src/supervisor/supervisor.js:97:12) at ProxyServer.emit (/usr/local/lib/node_modules/firebase-tools/node_modules/eventemitter3/index.js:144:27) at ClientRequest.proxyError (/usr/local/lib/node_modules/firebase-tools/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:156:18) at emitOne (events.js:101:20) at ClientRequest.emit (events.js:188:7) at Socket.socketOnEnd (_http_client.js:345:9) info: Execution took 61049 ms, finished with status: 'crash'

I'm not sure if these issues are related or not, let me know if they should be split into separate issues. For reference you can find my branch here.

davideast commented 6 years ago

@mrjmd Thanks for filling the issue! This module assumes a ** route currently, so I'm not sure if that is affecting you. Are you trying to apply any middleware?

mrjmd commented 6 years ago

There isn't any middleware, no. I'm going to try to reproduce / isolate the problem on a base CLI project.