fix: replace redirect("back") with explicit paths for Express 5

Express 5 removed the "back" magic keyword from response.redirect().
It was treated as a literal URL, causing 404s at /admin/featured/back
and /admin/tags/back. Now redirects to the correct parent pages.
This commit is contained in:
Ricardo
2026-02-21 00:17:56 +01:00
parent 71851eba9b
commit d46aca0c93
4 changed files with 13 additions and 13 deletions
+4 -4
View File
@@ -149,11 +149,11 @@ export default class ActivityPubEndpoint {
router.get("/admin/following", followingController(mp)); router.get("/admin/following", followingController(mp));
router.get("/admin/activities", activitiesController(mp)); router.get("/admin/activities", activitiesController(mp));
router.get("/admin/featured", featuredGetController(mp)); router.get("/admin/featured", featuredGetController(mp));
router.post("/admin/featured/pin", featuredPinController()); router.post("/admin/featured/pin", featuredPinController(mp));
router.post("/admin/featured/unpin", featuredUnpinController()); router.post("/admin/featured/unpin", featuredUnpinController(mp));
router.get("/admin/tags", featuredTagsGetController(mp)); router.get("/admin/tags", featuredTagsGetController(mp));
router.post("/admin/tags/add", featuredTagsAddController()); router.post("/admin/tags/add", featuredTagsAddController(mp));
router.post("/admin/tags/remove", featuredTagsRemoveController()); router.post("/admin/tags/remove", featuredTagsRemoveController(mp));
router.get("/admin/profile", profileGetController(mp)); router.get("/admin/profile", profileGetController(mp));
router.post("/admin/profile", profilePostController(mp)); router.post("/admin/profile", profilePostController(mp));
router.get("/admin/migrate", migrateGetController(mp, this.options)); router.get("/admin/migrate", migrateGetController(mp, this.options));
+4 -4
View File
@@ -24,7 +24,7 @@ export function featuredTagsGetController(mountPath) {
}; };
} }
export function featuredTagsAddController() { export function featuredTagsAddController(mountPath) {
return async (request, response, next) => { return async (request, response, next) => {
try { try {
const { application } = request.app.locals; const { application } = request.app.locals;
@@ -44,14 +44,14 @@ export function featuredTagsAddController() {
{ upsert: true }, { upsert: true },
); );
response.redirect("back"); response.redirect(`${mountPath}/admin/tags`);
} catch (error) { } catch (error) {
next(error); next(error);
} }
}; };
} }
export function featuredTagsRemoveController() { export function featuredTagsRemoveController(mountPath) {
return async (request, response, next) => { return async (request, response, next) => {
try { try {
const { application } = request.app.locals; const { application } = request.app.locals;
@@ -63,7 +63,7 @@ export function featuredTagsRemoveController() {
await collection.deleteOne({ tag }); await collection.deleteOne({ tag });
response.redirect("back"); response.redirect(`${mountPath}/admin/tags`);
} catch (error) { } catch (error) {
next(error); next(error);
} }
+4 -4
View File
@@ -69,7 +69,7 @@ export function featuredGetController(mountPath) {
}; };
} }
export function featuredPinController() { export function featuredPinController(mountPath) {
return async (request, response, next) => { return async (request, response, next) => {
try { try {
const { application } = request.app.locals; const { application } = request.app.locals;
@@ -90,14 +90,14 @@ export function featuredPinController() {
{ upsert: true }, { upsert: true },
); );
response.redirect("back"); response.redirect(`${mountPath}/admin/featured`);
} catch (error) { } catch (error) {
next(error); next(error);
} }
}; };
} }
export function featuredUnpinController() { export function featuredUnpinController(mountPath) {
return async (request, response, next) => { return async (request, response, next) => {
try { try {
const { application } = request.app.locals; const { application } = request.app.locals;
@@ -109,7 +109,7 @@ export function featuredUnpinController() {
await collection.deleteOne({ postUrl }); await collection.deleteOne({ postUrl });
response.redirect("back"); response.redirect(`${mountPath}/admin/featured`);
} catch (error) { } catch (error) {
next(error); next(error);
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@rmdes/indiekit-endpoint-activitypub", "name": "@rmdes/indiekit-endpoint-activitypub",
"version": "1.0.27", "version": "1.0.28",
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.", "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
"keywords": [ "keywords": [
"indiekit", "indiekit",