mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-02 02:11:20 +00:00
Merge cbe6075fc8 into cfa6c7cb17
This commit is contained in:
commit
d701b9e25d
2 changed files with 22 additions and 2 deletions
|
|
@ -443,8 +443,18 @@ export const apiSchema = createSchema({
|
|||
},
|
||||
})
|
||||
|
||||
function normalizeBackendV3BaseURL(rawBaseURL: string): string {
|
||||
// Allow passing either "https://api.supermemory.ai" or "https://api.supermemory.ai/v3"
|
||||
// (and tolerate trailing slashes) without accidentally producing "/v3/v3".
|
||||
const trimmed = rawBaseURL.replace(/\/+$/, "")
|
||||
return trimmed.endsWith("/v3") ? trimmed : `${trimmed}/v3`
|
||||
}
|
||||
|
||||
const backendBaseURL =
|
||||
process.env.NEXT_PUBLIC_BACKEND_URL ?? "https://api.supermemory.ai"
|
||||
|
||||
export const $fetch = createFetch({
|
||||
baseURL: `${process.env.NEXT_PUBLIC_BACKEND_URL ?? "https://api.supermemory.ai"}/v3`,
|
||||
baseURL: normalizeBackendV3BaseURL(backendBaseURL),
|
||||
credentials: "include",
|
||||
headers: { "X-App-Source": "nova" },
|
||||
onRequest: (context: { headers: Headers }) => {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,18 @@ import {
|
|||
} from "better-auth/client/plugins"
|
||||
import { createAuthClient } from "better-auth/react"
|
||||
|
||||
function normalizeBackendBaseURL(rawBaseURL: string): string {
|
||||
// Accept either "https://api.supermemory.ai" or "https://api.supermemory.ai/v3".
|
||||
// Auth endpoints are mounted at the root base (not under /v3).
|
||||
const trimmed = rawBaseURL.replace(/\/+$/, "")
|
||||
return trimmed.endsWith("/v3") ? trimmed.slice(0, -3) : trimmed
|
||||
}
|
||||
|
||||
const backendBaseURL =
|
||||
process.env.NEXT_PUBLIC_BACKEND_URL ?? "https://api.supermemory.ai"
|
||||
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: process.env.NEXT_PUBLIC_BACKEND_URL ?? "https://api.supermemory.ai",
|
||||
baseURL: normalizeBackendBaseURL(backendBaseURL),
|
||||
fetchOptions: {
|
||||
credentials: "include",
|
||||
headers: { "X-App-Source": "nova" },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue