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

Crashes when no Authorization header is available #9

Open
pablof7z opened this issue Apr 22, 2023 · 2 comments
Open

Crashes when no Authorization header is available #9

pablof7z opened this issue Apr 22, 2023 · 2 comments

Comments

@pablof7z
Copy link

file:///home/pablo/nosdav/server/index.js:161
  const nostr = headers.authorization.replace('Nostr ', '')
                                      ^

TypeError: Cannot read properties of undefined (reading 'replace')
    at handlePut (file:///home/pablo/nosdav/server/index.js:161:39)
    at Server.handleRequest (file:///home/pablo/nosdav/server/index.js:33:7)
    at Server.emit (node:events:513:28)
    at parserOnIncoming (node:_http_server:1065:12)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)

Node.js v18.13.0
@melvincarvalho
Copy link
Contributor

Thanks for the report, I'll look at this probably later today, just finishing the profile proof of concept.

@melvincarvalho
Copy link
Contributor

I've changed

  const nostr = headers.authorization.replace('Nostr ', '')

to

  const nostr = headers?.authorization?.replace('Nostr ', '')
  console.log('nostr auth header', nostr)

in handlePut

This should prevent the crash.

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

No branches or pull requests

2 participants