Changeset 89cc8c4 in Klonkt


Ignore:
Timestamp:
06/28/2026 12:03:28 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
a995698
Parents:
5b1115b
Message:

fix(fedi): turning AP off no longer 404s the whole site

The AP router is mounted at root, so its 'if (!apEnabled()) return res.status(404)' guard ran
for EVERY request and 404'd the entire site when federation was switched off. Now it uses
next('router') to skip the router so the normal routes handle the request; /ap/* still 404s
naturally when AP is off.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/routes/activitypub.js

    r5b1115b r89cc8c4  
    2222// The whole fediverse layer can be turned off (solo "no federation" mode):
    2323// then /ap/*, WebFinger and NodeInfo are simply gone — the site is undiscoverable
    24 // and unfederatable.
    25 router.use((req, res, next) => { if (!apEnabled()) return res.status(404).end(); next(); });
     24// and unfederatable. CRITICAL: this router is mounted at root (app.use(apRoutes)), so a
     25// blanket res.status(404) here ran for EVERY request and 404'd the whole site when AP was
     26// off. Use next('router') to SKIP this router entirely and let the normal routes handle it
     27// (the /ap/* paths then fall through to the app's normal 404, which is correct).
     28router.use((req, res, next) => { if (!apEnabled()) return next('router'); next(); });
    2629// Generous per-IP baseline over all /ap/* (reads). The inbox POST gets an
    2730// additional, tighter cap inline (it triggers outbound fetches).
Note: See TracChangeset for help on using the changeset viewer.