User Wintermute reports an issue where certain API routes return HTML instead of JSON, despite identical code working for other routes — and the same URL returning JSON correctly when accessed via Chrome. The problematic endpoint is u/{user}/activity.json, which returns HTML when fetched via fetch(), while u/{user}.json works as expected. simon suggests using user_actions.json?username={user} as a working alternative, which Wintermute confirms returns the needed data — but questions why the original path fails, noting it’s used in the browser’s Network tab. Later, Wintermute reports the issue persists intermittently when fetching individual posts via /posts/{id}, sometimes succeeding and sometimes failing with “Unexpected token <” — suggesting a backend inconsistency. The user suspects a Discourse bug or misconfiguration, though not being the site admin, they’re seeking guidance before requesting changes.
returns json as expected. And even stranger, pasting the faulty URL into Chrome returns JSON as expected!
Any suggestions? Is this a discourse bug? Did I set something up wrong? I’m not the site admin but can request to get things fixed if it’s a site setup issue.
If you visit a user’s activity page on Discourse and view the Network tab of your browser’s developer tools, you’ll see that a GET request is made to a URL similar to:
Does return the content that I need. However, shouldn’t the original path also work? You can see it being called in the network tab when accessing the user activity page and it’s got .json? appended to it.