Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

When using bare server mode with scramjet or ultraviolet, clients receive HTML instead of JSON from /bare/ endpoints, causing SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON. Wisp server mode works correctly.

Changes

Added explicit path-based routing for bare server requests before shouldRoute() check:

// Before: relied solely on shouldRoute()
if (bareServer.shouldRoute(req)) {
    bareServer.routeRequest(req, res);
}

// After: explicit path check provides defensive routing
if (req.url && req.url.startsWith("/bare/")) {
    bareServer.routeRequest(req, res);
} else if (bareServer.shouldRoute(req)) {
    bareServer.routeRequest(req, res);
}

Applied to both HTTP request and WebSocket upgrade handlers in server/index.ts. Ensures all /bare/ paths route to bare server, preventing fallthrough to Astro's HTML handler.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: node server/index.js (dns block)
  • telemetry.astro.build
    • Triggering command: node /home/REDACTED/work/Radius/Radius/node_modules/.bin/astro build (dns block)
  • www.google.com
    • Triggering command: node server/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

fix the bare server system, as when attempting to use on localhost useing either scramjet or ultravilot, the error message SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON and Message: Unexpected token '<', "<!DOCTYPE "... is not valid JSON appears. however, when using the wisp server, the system works normaly.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@codesandbox
Copy link

codesandbox bot commented Nov 10, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@vercel
Copy link

vercel bot commented Nov 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
radius Error Error Nov 10, 2025 9:03pm

- Add direct URL check for /bare/ paths before shouldRoute()
- Ensure all bare server requests are routed correctly
- Prevent requests from falling through to Astro handler
- Fixes JSON parse errors when using bare server with scramjet/ultraviolet

Co-authored-by: sriail <[email protected]>
Copilot AI changed the title [WIP] Fix JSON parsing error in bare server system Fix bare server routing to prevent HTML responses on JSON endpoints Nov 10, 2025
Copilot AI requested a review from sriail November 10, 2025 21:11
Copilot finished work on behalf of sriail November 10, 2025 21:11
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.

2 participants