Akryum / vue-cli-plugin-ssr

:sparkles: Simple SSR plugin for Vue CLI
https://vue-cli-plugin-ssr.netlify.com/
MIT License
444 stars 69 forks source link

Requests fail with cookie array in response #243

Closed thedevelopnik closed 3 years ago

thedevelopnik commented 3 years ago

I'm trying to use this package on a frontend that calls to a separate api server backend. We use both http calls and websocket calls to our api server.

To authorize socket.io calls, we use passport.socketio.

When the server responds on some calls, the set-cookie header value is an array like

[
  'connect.sid=s%3AeODRhnwCbuiu52PzC_6btWU9a97AiLrZ.wJdgzYFf2oG%2Fq2HOZUPfxWFoc0wtp6z8WEcVyleeAHI; Path=/; Expires=Tue, 02 Feb 2021 05:34:07 GMT'
]

In vue-resource.common.js, in the nodeClient this fails because it tries to call str.replace on all header values. The stack trace I'm getting is

(node:26048) UnhandledPromiseRejectionWarning: TypeError: str.replace is not a function
    at trim (/home/davesudia/code/upchieve/web/node_modules/vue-resource/dist/vue-resource.common.js:299:22)
    at Headers.set (/home/davesudia/code/upchieve/web/node_modules/vue-resource/dist/vue-resource.common.js:1216:65)
    at Array.<anonymous> (/home/davesudia/code/upchieve/web/node_modules/vue-resource/dist/vue-resource.common.js:1117:34)
    at each (/home/davesudia/code/upchieve/web/node_modules/vue-resource/dist/vue-resource.common.js:382:26)
    at handler (/home/davesudia/code/upchieve/web/node_modules/vue-resource/dist/vue-resource.common.js:1116:13)
    at /home/davesudia/code/upchieve/web/node_modules/vue-resource/dist/vue-resource.common.js:1122:41
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:26048) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 17)

I'm having a hard time figuring out what in the ssr plugin is calling this. Happy to help with contributions if I can get help tracking down a fix. Thanks for any assistance!

Also happy to provide more info and clarification. It's late and I've been in this code for a few hours and the above may not be super clear.

thedevelopnik commented 3 years ago

I'm actually starting to wonder if this has less to do with this package and more with how this package runs in node instead of the browser, and if that promise catch has been silently failing and now the way this is running is catching it.

thedevelopnik commented 3 years ago

The effect is that the ssr server run from npm run ssr:serve never responds. The request hangs in a pending state.