mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
feat(api): ✨ Redirect browsers to frontend when accessing raw Lysand objects
This commit is contained in:
parent
cf5684cf26
commit
757eb835e9
|
|
@ -1,5 +1,5 @@
|
|||
import { applyConfig, handleZodError } from "@/api";
|
||||
import { errorResponse, jsonResponse, response } from "@/response";
|
||||
import { errorResponse, jsonResponse, redirect, response } from "@/response";
|
||||
import type { Hono } from "@hono/hono";
|
||||
import { zValidator } from "@hono/zod-validator";
|
||||
import { z } from "zod";
|
||||
|
|
@ -58,6 +58,11 @@ export default (app: Hono) =>
|
|||
});
|
||||
}
|
||||
|
||||
// Try to detect a web browser and redirect to the user's profile page
|
||||
if (context.req.header("user-agent")?.includes("Mozilla")) {
|
||||
return redirect(user.toApi().url);
|
||||
}
|
||||
|
||||
return jsonResponse(user.toLysand());
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue