mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 11:23:10 +02:00
fix: send Supabase token on raw fetch in SaaS chat
This commit is contained in:
@@ -100,8 +100,11 @@ async function refreshAuthToken(client: AxiosInstance): Promise<string> {
|
||||
}
|
||||
}
|
||||
|
||||
/** Auth headers for raw fetch() calls (SSE streams, etc.). */
|
||||
export function getAuthHeaders(): Record<string, string> {
|
||||
/**
|
||||
* Auth headers for raw fetch() calls (SSE streams, etc.).
|
||||
* Async to match the SaaS override, which has to await the Supabase session.
|
||||
*/
|
||||
export async function getAuthHeaders(): Promise<Record<string, string>> {
|
||||
const headers: Record<string, string> = {};
|
||||
const jwt = getJwtTokenFromStorage();
|
||||
if (jwt) {
|
||||
@@ -117,8 +120,8 @@ export function getAuthHeaders(): Record<string, string> {
|
||||
export function setupApiInterceptors(client: AxiosInstance): void {
|
||||
// Install request interceptor to add JWT token
|
||||
client.interceptors.request.use(
|
||||
(config) => {
|
||||
const authHeaders = getAuthHeaders();
|
||||
async (config) => {
|
||||
const authHeaders = await getAuthHeaders();
|
||||
for (const [key, value] of Object.entries(authHeaders)) {
|
||||
if (!config.headers[key]) {
|
||||
config.headers[key] = value;
|
||||
|
||||
Reference in New Issue
Block a user