mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-16 11:14:44 +08:00
25 lines
557 B
TypeScript
25 lines
557 B
TypeScript
import { getToken } from "next-auth/jwt";
|
|
|
|
const handler = async (req, res) => {
|
|
const token = await getToken({ req });
|
|
|
|
// Return nothing if the user isn't registered.
|
|
if (!token) {
|
|
res.status(401).end();
|
|
return;
|
|
}
|
|
|
|
const messagesRes = await fetch(`${process.env.FASTAPI_URL}/api/v1/messages`, {
|
|
method: "GET",
|
|
headers: {
|
|
"X-API-Key": process.env.FASTAPI_KEY,
|
|
},
|
|
});
|
|
const messages = await messagesRes.json();
|
|
|
|
// Send recieved messages to the client.
|
|
res.status(200).json(messages);
|
|
};
|
|
|
|
export default handler;
|