Fix SambaPOS GraphQL token URL: derive from origin so /api/graphql suffix in endpoint field doesn't break it

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-14 13:45:52 +00:00
parent d6449d8b52
commit 6dc5df45e5

View file

@ -161,7 +161,7 @@ export async function integrationRoutes(app) {
try { try {
if (!creds.graphql_endpoint || !creds.graphql_username || !creds.graphql_password || !creds.graphql_client_id) if (!creds.graphql_endpoint || !creds.graphql_username || !creds.graphql_password || !creds.graphql_client_id)
throw new Error('GraphQL endpoint, username, password and client ID are required') throw new Error('GraphQL endpoint, username, password and client ID are required')
const base = creds.graphql_endpoint.replace(/\/$/, '') const base = new URL(creds.graphql_endpoint).origin
const tokenRes = await fetch(`${base}/Token`, { const tokenRes = await fetch(`${base}/Token`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' },