Fix for #10403 - when app overview loads, sometimes old store doesn't get a valid app ID.

This commit is contained in:
Michael Drury 2023-04-24 20:39:39 +01:00
parent dfe28d171c
commit 14545729ac
1 changed files with 6 additions and 2 deletions

View File

@ -5,12 +5,16 @@ import {
} from "@budibase/frontend-core"
import { store } from "./builderStore"
import { get } from "svelte/store"
import { auth } from "./stores/portal"
import { auth, overview } from "./stores/portal"
export const API = createAPIClient({
attachHeaders: headers => {
// Attach app ID header from store
headers["x-budibase-app-id"] = get(store).appId
let appId = get(store).appId
if (!appId) {
appId = get(overview).selectedAppId
}
headers["x-budibase-app-id"] = appId
// Add csrf token if authenticated
const user = get(auth).user