feat: add authentication token handling for design persistence
This commit is contained in:
@@ -128,8 +128,12 @@ const persistDesign = async (designId: string, design: ExportedDesign) => {
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Get Firebase ID token for authentication
|
||||||
|
const idToken = user.value ? await user.value.getIdToken() : null;
|
||||||
|
|
||||||
await $fetch("/api/designs", {
|
await $fetch("/api/designs", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
headers: idToken ? { Authorization: `Bearer ${idToken}` } : {},
|
||||||
body: {
|
body: {
|
||||||
designId,
|
designId,
|
||||||
templateId: design.templateId,
|
templateId: design.templateId,
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ export default defineEventHandler(async (event) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract the authorization token from the incoming request
|
||||||
|
const authHeader = getHeader(event, "authorization");
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
designId: body.designId,
|
designId: body.designId,
|
||||||
templateId: body.templateId,
|
templateId: body.templateId,
|
||||||
@@ -43,6 +46,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
const result = await $fetch("/designs", {
|
const result = await $fetch("/designs", {
|
||||||
baseURL: backendUrl,
|
baseURL: backendUrl,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
headers: authHeader ? { Authorization: authHeader } : {},
|
||||||
body: payload,
|
body: payload,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user