FEAT: Implement authenticated internal API call utility to forward cookies and enhance authentication handling

This commit is contained in:
2025-06-15 17:48:40 +02:00
parent a7df6834d7
commit 3a83831a20
5 changed files with 216 additions and 21 deletions

View File

@@ -174,13 +174,15 @@ export default defineEventHandler(async (event) => {
});
}
// Get linked berths - use the same auth as this request (either x-tag or session)
const xTagHeader = getRequestHeader(event, "x-tag");
// Get linked berths - forward the authentication cookies for internal API call
const cookies = getRequestHeader(event, "cookie");
const requestHeaders: Record<string, string> = {};
if (xTagHeader) {
requestHeaders["x-tag"] = xTagHeader;
if (cookies) {
requestHeaders["cookie"] = cookies;
}
console.log('[generate-eoi] Making internal API call to get-interest-berths with forwarded cookies');
const berthsResponse = await $fetch<{ list: Array<{ 'Mooring Number': string }> }>(
"/api/get-interest-berths",
{