Hey @julian, can you help me with a quick debugging session?
-
wrote 25 days ago last edited by
Hey @julian, can you help me with a quick debugging session?
Why would ` curl 'https://forum.wedistribute.org/category/5/fediverse' -H 'Accept: application/activity+json, application/ld+json'
`return the expected JSON LD representing the actor, but the exact equivalent request fail with node.js?
-
Hey @julian, can you help me with a quick debugging session?
Why would ` curl 'https://forum.wedistribute.org/category/5/fediverse' -H 'Accept: application/activity+json, application/ld+json'
`return the expected JSON LD representing the actor, but the exact equivalent request fail with node.js?
wrote 25 days ago last edited by@raphael@mastodon.communick.com hmm interesting, can you share the code that's making the call?
Usually if it's working with
curl
it'll work with Node, so this suggests there's something different with the way the call is made with node.For what it's worth, internally, NodeBB uses the built-in
fetch
method from Node.js. -
@raphael@mastodon.communick.com hmm interesting, can you share the code that's making the call?
Usually if it's working with
curl
it'll work with Node, so this suggests there's something different with the way the call is made with node.For what it's worth, internally, NodeBB uses the built-in
fetch
method from Node.js.wrote 25 days ago last edited bytypescript code
```
const REQUEST_OPTIONS = {
redirect: 'follow' as RequestRedirect,
headers: { 'Accept': 'application/activitypub+json, application/ld+json' },
'User-Agent': 'curl/8.12.1'
}const response = await fetch('https://forum.wedistribute.org/category/5/fediverse', REQUEST_OPTIONS)
try {
return await response.json()
}
catch(exc) {
console.log(response.url)
console.log(response.headers)
throw exc
}
``` -
typescript code
```
const REQUEST_OPTIONS = {
redirect: 'follow' as RequestRedirect,
headers: { 'Accept': 'application/activitypub+json, application/ld+json' },
'User-Agent': 'curl/8.12.1'
}const response = await fetch('https://forum.wedistribute.org/category/5/fediverse', REQUEST_OPTIONS)
try {
return await response.json()
}
catch(exc) {
console.log(response.url)
console.log(response.headers)
throw exc
}
```wrote 25 days ago last edited byIt fails if I just use "/category/5" url (without the fediverse at the end), it fails if go straight to the redirected url (with "/fediverse?lang=en-US").
It also fails if I use the curl User-Agent, or if I don't use any user agent at all.
-
It fails if I just use "/category/5" url (without the fediverse at the end), it fails if go straight to the redirected url (with "/fediverse?lang=en-US").
It also fails if I use the curl User-Agent, or if I don't use any user agent at all.