api endpoint fix for me
This commit is contained in:
parent
ab639edc7a
commit
d1b0a77a5e
2 changed files with 188 additions and 123 deletions
|
|
@ -8,18 +8,13 @@ function readCookie(name: string, cookieHeader: string) {
|
|||
|
||||
export async function GET(req: Request) {
|
||||
const base = process.env.NEXT_PUBLIC_API_BASE_URL!;
|
||||
// ⬇️ include username
|
||||
// include username so the form can show it
|
||||
const url = `${base}/users/me?fields=id,username,display_name,first_name,last_name,email`;
|
||||
|
||||
// Forward the raw Cookie header (covers your session)…
|
||||
const cookieHeader = req.headers.get("cookie") ?? "";
|
||||
|
||||
// …and also send ma_at as Bearer for token-based setups.
|
||||
const ma_at = readCookie("ma_at", cookieHeader);
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
"cache-control": "no-store",
|
||||
};
|
||||
const headers: Record<string, string> = { "cache-control": "no-store" };
|
||||
if (cookieHeader) headers.cookie = cookieHeader;
|
||||
if (ma_at) headers.authorization = `Bearer ${ma_at}`;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue