Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing base in URL() constructor #735

Merged
merged 1 commit into from
Jul 8, 2019

Conversation

frsechet
Copy link
Contributor

@frsechet frsechet commented Jul 8, 2019

As req.url only contains the relative URL, the base URL parameter (or absolute input URL, either of those must be given) was missing from the new URL(req.url) call, which causes a crash on $connect action as it is unable to parse the query string parameters and throws with ERR_INVALID_URL.

@dnalborczyk
Copy link
Collaborator

hey @frsechet thank you! you are right.

that being said, I believe req.headers.host is also not guaranteed to exist, as it is a header.

there are many discussions about this topic of a replacement and the deprecation of [now legacy] url.parse.

in the meantime, I think the suggested option is to use a "dummy" base url: nodejs/node#12682 , e.g. http://www.example.com

@dnalborczyk dnalborczyk merged commit 181edbb into dherault:master Jul 8, 2019
@frsechet frsechet deleted the fs/fix/websockets-url branch July 8, 2019 12:41
@dherault
Copy link
Owner

dherault commented Jul 8, 2019

v5.7.2 🎉

@vinchi777
Copy link

Getting

TypeError: Cannot convert undefined or null to object
serverless-offline/src/ApiGatewayWebSocket.js:199

This kinda fixed it
if (queryStringParameters && Object.keys(queryStringParameters).length > 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants