mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
fix(federation): 🐛 Make nodeinfo correctly return JSON instead of redirect
This commit is contained in:
parent
bfbaa7ce2c
commit
1837a6feb4
|
|
@ -1,5 +1,5 @@
|
||||||
import { apiRoute, applyConfig } from "@/api";
|
import { apiRoute, applyConfig } from "@/api";
|
||||||
import { createRoute } from "@hono/zod-openapi";
|
import { createRoute, z } from "@hono/zod-openapi";
|
||||||
import { config } from "~/packages/config-manager";
|
import { config } from "~/packages/config-manager";
|
||||||
|
|
||||||
export const meta = applyConfig({
|
export const meta = applyConfig({
|
||||||
|
|
@ -18,20 +18,36 @@ const route = createRoute({
|
||||||
path: "/.well-known/nodeinfo",
|
path: "/.well-known/nodeinfo",
|
||||||
summary: "Well-known nodeinfo",
|
summary: "Well-known nodeinfo",
|
||||||
responses: {
|
responses: {
|
||||||
301: {
|
200: {
|
||||||
description: "Redirect to 2.0 Nodeinfo",
|
description: "Nodeinfo links",
|
||||||
|
content: {
|
||||||
|
"application/json": {
|
||||||
|
schema: z.object({
|
||||||
|
links: z.array(
|
||||||
|
z.object({
|
||||||
|
rel: z.string(),
|
||||||
|
href: z.string(),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default apiRoute((app) =>
|
export default apiRoute((app) =>
|
||||||
app.openapi(route, (context) => {
|
app.openapi(route, (context) => {
|
||||||
return context.redirect(
|
return context.json({
|
||||||
new URL(
|
links: [
|
||||||
"/.well-known/nodeinfo/2.0",
|
{
|
||||||
config.http.base_url,
|
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0",
|
||||||
).toString(),
|
href: new URL(
|
||||||
301,
|
"/.well-known/nodeinfo/2.0",
|
||||||
);
|
config.http.base_url,
|
||||||
|
).toString(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue