fix: set json content type for spacetime web api
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-27 16:54:38 +08:00
parent 9aae7afb2e
commit 1e4a64f542
2 changed files with 10 additions and 3 deletions

View File

@@ -105,10 +105,11 @@ export async function callSpacetimeProcedure(options, procedureName, input) {
const serverUrl = resolveServerUrl(options).replace(/\/+$/u, '');
const url = `${serverUrl}/v1/database/${encodeURIComponent(options.database)}/call/${encodeURIComponent(procedureName)}`;
const headers = {
'content-type': 'application/json; charset=utf-8',
Accept: 'application/json',
'Content-Type': 'application/json',
};
if (options.token) {
headers.authorization = `Bearer ${options.token}`;
headers.Authorization = `Bearer ${options.token}`;
}
let response;
@@ -136,9 +137,13 @@ export async function callSpacetimeProcedure(options, procedureName, input) {
export async function createSpacetimeWebIdentity(options) {
const serverUrl = resolveServerUrl(options).replace(/\/+$/u, '');
const url = `${serverUrl}/v1/identity`;
const headers = {
Accept: 'application/json',
'Content-Type': 'application/json',
};
let response;
try {
response = await fetch(url, { method: 'POST' });
response = await fetch(url, { method: 'POST', headers });
} catch (error) {
throw new Error(
`SpacetimeDB identity 请求失败: ${url}; ${error instanceof Error ? error.message : String(error)}`,