Problem
When accessing a protected resource directly in the browser (e.g., http://jss:4000/demo/), the server returns raw JSON:
{"error":"Unauthorized","message":"Authentication required"}
This prevents users from logging in because mashlib never loads.
Expected Behavior
When a browser request (Accept: text/html) hits a 401 or 403, the server should return mashlib HTML so users can:
- See the data browser interface
- Click "Log in" to authenticate
- Access the protected resource after authentication
This is how NSS (Node Solid Server) behaves.
Proposed Solution
Modify handleUnauthorized in src/auth/middleware.js to:
- Check if request accepts
text/html and mashlib is enabled
- Return mashlib HTML with appropriate status code (401/403) instead of JSON
- Pass request object to
handleUnauthorized to access Accept header and mashlib settings
Files to Modify
src/auth/middleware.js - Update handleUnauthorized function
src/server.js - Pass request to handleUnauthorized call
Problem
When accessing a protected resource directly in the browser (e.g.,
http://jss:4000/demo/), the server returns raw JSON:{"error":"Unauthorized","message":"Authentication required"}This prevents users from logging in because mashlib never loads.
Expected Behavior
When a browser request (
Accept: text/html) hits a 401 or 403, the server should return mashlib HTML so users can:This is how NSS (Node Solid Server) behaves.
Proposed Solution
Modify
handleUnauthorizedinsrc/auth/middleware.jsto:text/htmland mashlib is enabledhandleUnauthorizedto access Accept header and mashlib settingsFiles to Modify
src/auth/middleware.js- UpdatehandleUnauthorizedfunctionsrc/server.js- Pass request tohandleUnauthorizedcall