fix(api,web): add workspace context to widgets and auto-detect workspace ID (#532)
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #532.
This commit is contained in:
@@ -202,9 +202,13 @@ export async function apiRequest<T>(endpoint: string, options: ApiRequestOptions
|
||||
...baseHeaders,
|
||||
};
|
||||
|
||||
// Add workspace ID header if provided (recommended over query string)
|
||||
if (workspaceId) {
|
||||
headers["X-Workspace-Id"] = workspaceId;
|
||||
// Add workspace ID header — use explicit value, or auto-detect from localStorage
|
||||
const resolvedWorkspaceId =
|
||||
workspaceId ??
|
||||
(typeof window !== "undefined" ? localStorage.getItem("mosaic-workspace-id") : null) ??
|
||||
undefined;
|
||||
if (resolvedWorkspaceId) {
|
||||
headers["X-Workspace-Id"] = resolvedWorkspaceId;
|
||||
}
|
||||
|
||||
// Add CSRF token for state-changing requests (POST, PUT, PATCH, DELETE)
|
||||
|
||||
Reference in New Issue
Block a user