GitHub user thiagogquinto added a comment to the discussion: Login redirection does not use subpath prefix
backen env: SUPERSET_URL=http://superset:8088/analytics superset env: SUPERSET_APP_ROOT="/analytics" Erro ao gerar Guest Token: [TypeError: fetch failed] { [cause]: Error: Client network socket disconnected before secure TLS connection was established at TLSSocket.onConnectEnd (node:internal/tls/wrap:1800:19) at TLSSocket.emit (node:events:521:24) at endReadableNT (node:internal/streams/readable:1729:12) at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { code: 'ECONNRESET', path: undefined, host: 'superset', port: '8088', localAddress: null } } import { Injectable, InternalServerErrorException } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; @Injectable() export class SupersetService { private cachedAccessToken: string | null = null; private readonly supersetUrl: string; constructor(private configService: ConfigService) { this.supersetUrl = this.configService.get<string>('SUPERSET_URL', 'http://localhost:8088'); } async getGuestTokenFromSuperset(dashboardId: string): Promise<string> { try { const accessToken = await this.getAccessTokenFromSuperset(); const response = await fetch(`${this.supersetUrl}/api/v1/security/guest_token/`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ user: { username: "", first_name: "", last_name: "" }, resources: [ { type: "dashboard", id: dashboardId } ], rls: [] }), }); if (!response.ok) { // Pega o JSON ou texto que explica o motivo do 400 const errorDetails = await response.text(); console.error(`Detalhes do erro do Superset:`, errorDetails); throw new Error(`Erro do Superset: ${response.status} - ${errorDetails}`); } const data = await response.json(); return data.token; } catch (error) { console.error('Erro ao gerar Guest Token:', error); console.error('Detalhes do erro:', error instanceof Error ? error.message : error); throw new InternalServerErrorException('Falha ao obter o token de convidado do Superset'); } } private async getAccessTokenFromSuperset(): Promise<string> { if (this.cachedAccessToken) { return this.cachedAccessToken; } const supersetAdmin = this.configService.get<string>('SUPERSET_ADMIN', 'admin'); const supersetAdminPassword = this.configService.get<string>('SUPERSET_ADMIN_PASSWORD', ''); const response = await fetch(`${this.supersetUrl}/api/v1/security/login`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ username: supersetAdmin, password: supersetAdminPassword, provider: 'db', refresh: true, }), }); if (!response.ok) { throw new Error('Credenciais inválidas ou erro no Superset'); } const data = await response.json(); this.cachedAccessToken = data.access_token; return this.cachedAccessToken; } } what is the problem? @dosu GitHub link: https://github.com/apache/superset/discussions/40082#discussioncomment-17663144 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
