Skip to content

Fix frontend api url#1

Merged
rnarciso merged 2 commits intomainfrom
fix-frontend-api-url
Aug 15, 2025
Merged

Fix frontend api url#1
rnarciso merged 2 commits intomainfrom
fix-frontend-api-url

Conversation

@rnarciso
Copy link
Copy Markdown
Owner

@rnarciso rnarciso commented Aug 15, 2025

Pull Request

Summary

Changes Made

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Affected Services

  • Frontend (React UI)
  • Server (FastAPI backend)
  • MCP Server (Model Context Protocol)
  • Agents (PydanticAI service)
  • Database (migrations/schema)
  • Docker/Infrastructure
  • Documentation site

Testing

  • All existing tests pass
  • Added new tests for new functionality
  • Manually tested affected user flows
  • Docker builds succeed for all services

Test Evidence

# Example: python -m pytest tests/
# Example: cd archon-ui-main && npm run test

Checklist

  • My code follows the service architecture patterns
  • If using an AI coding assistant, I used the CLAUDE.md rules
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass locally
  • My changes generate no new warnings
  • I have updated relevant documentation
  • I have verified no regressions in existing features

Breaking Changes

Additional Notes

Resumo por Sourcery

Retornar URLs de API relativas para todos os ambientes e unificar a geração de UUID usando o pacote uuid

Melhorias:

  • Simplificar a resolução de URL da API do front-end para sempre usar um caminho relativo, removendo a lógica de host personalizada para dev/prod
  • Substituir o uso de crypto.randomUUID por uuidv4 para IDs de execução e adicionar uuid e seus tipos como dependências
Original summary in English

Summary by Sourcery

Return relative API URLs for all environments and unify UUID generation using the uuid package

Enhancements:

  • Simplify front-end API URL resolution to always use a relative path, removing custom dev/prod host logic
  • Replace usage of crypto.randomUUID with uuidv4 for execution IDs and add uuid and its types as dependencies

The frontend was failing to communicate with the backend in development because it was constructing an absolute URL for API requests, bypassing the Vite proxy.

This change modifies the `getApiUrl` function in `src/config/api.ts` to return a relative path ('') in development mode. This ensures all API and WebSocket requests are correctly proxied by the Vite dev server, resolving the connection and CORS issues.
The React UI tests were failing in environments with older Node.js versions due to the use of `crypto.randomUUID()`, which is not universally available.

This commit replaces the call to `crypto.randomUUID()` in `src/services/testService.ts` with `uuidv4()` from the `uuid` library. The `uuid` library and its types have been added to the project dependencies.

This ensures compatibility and allows the UI tests to run correctly across different development environments.
@rnarciso rnarciso merged commit d5a7649 into main Aug 15, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Aug 15, 2025

Guia do Revisor (colapsado em PRs pequenos)

Guia do Revisor

Este PR simplifica a configuração da URL da API do frontend, removendo a ramificação baseada no ambiente para sempre usar um caminho relativo, muda a geração de UUID no serviço de teste para a biblioteca uuid e atualiza as dependências de acordo.

Diagrama de Classe para atualização da geração de UUID do TestService

classDiagram
class TestService {
  +runTest()
}
TestService --> uuidv4 : uses

class uuidv4 {
  <<function>>
}
Loading

Alterações a Nível de Arquivo

Alteração Detalhes Arquivos
Padronizar a resolução da URL da API para um caminho relativo
  • Removida a ramificação de produção e desenvolvimento em getApiUrl
  • Sempre retorna uma string de caminho relativo para dev e prod
  • Comentários de código atualizados para clarificar o comportamento do proxy
archon-ui-main/src/config/api.ts
Mudar a geração de UUID para a biblioteca uuid
  • Importado v4 as uuidv4 from 'uuid'
  • Substituído crypto.randomUUID() por uuidv4() para IDs de execução
archon-ui-main/src/services/testService.ts
Adicionar dependências uuid
  • Adicionado "uuid" às dependências do projeto
  • Adicionado "@types/uuid" às devDependencies
archon-ui-main/package.json

Dicas e comandos

Interagindo com o Sourcery

  • Acionar uma nova revisão: Comente @sourcery-ai review no pull request.
  • Continuar discussões: Responda diretamente aos comentários de revisão do Sourcery.
  • Gerar um problema GitHub a partir de um comentário de revisão: Peça ao Sourcery para criar um problema a partir de um comentário de revisão, respondendo a ele. Você também pode responder a um comentário de revisão com @sourcery-ai issue para criar um problema a partir dele.
  • Gerar um título de pull request: Escreva @sourcery-ai em qualquer lugar no título do pull request para gerar um título a qualquer momento. Você também pode comentar @sourcery-ai title no pull request para (re)gerar o título a qualquer momento.
  • Gerar um resumo de pull request: Escreva @sourcery-ai summary em qualquer lugar no corpo do pull request para gerar um resumo do PR a qualquer momento, exatamente onde você quiser. Você também pode comentar @sourcery-ai summary no pull request para (re)gerar o resumo a qualquer momento.
  • Gerar guia do revisor: Comente @sourcery-ai guide no pull request para (re)gerar o guia do revisor a qualquer momento.
  • Resolver todos os comentários do Sourcery: Comente @sourcery-ai resolve no pull request para resolver todos os comentários do Sourcery. Útil se você já resolveu todos os comentários e não quer mais vê-los.
  • Descartar todas as revisões do Sourcery: Comente @sourcery-ai dismiss no pull request para descartar todas as revisões existentes do Sourcery. Especialmente útil se você quiser começar do zero com uma nova revisão - não se esqueça de comentar @sourcery-ai review para acionar uma nova revisão!

Personalizando Sua Experiência

Acesse seu painel para:

  • Habilitar ou desabilitar recursos de revisão, como o resumo do pull request gerado pelo Sourcery, o guia do revisor e outros.
  • Alterar o idioma da revisão.
  • Adicionar, remover ou editar instruções de revisão personalizadas.
  • Ajustar outras configurações de revisão.

Obtendo Ajuda

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR simplifies the frontend API URL configuration by removing environment-based branching to always use a relative path, switches UUID generation in the test service to the uuid library, and updates dependencies accordingly.

Class diagram for TestService UUID generation update

classDiagram
class TestService {
  +runTest()
}
TestService --> uuidv4 : uses

class uuidv4 {
  <<function>>
}
Loading

File-Level Changes

Change Details Files
Standardize API URL resolution to a relative path
  • Removed production and development branching in getApiUrl
  • Always return a relative path string for both dev and prod
  • Updated code comments to clarify proxy behavior
archon-ui-main/src/config/api.ts
Switch UUID generation to the uuid library
  • Imported v4 as uuidv4 from 'uuid'
  • Replaced crypto.randomUUID() with uuidv4() for execution IDs
archon-ui-main/src/services/testService.ts
Add uuid dependencies
  • Added "uuid" to project dependencies
  • Added "@types/uuid" to devDependencies
archon-ui-main/package.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Olá - Revisei suas alterações e elas parecem ótimas!


Sourcery é gratuito para código aberto - se você gosta de nossas revisões, considere compartilhá-las ✨
Ajude-me a ser mais útil! Por favor, clique em 👍 ou 👎 em cada comentário e usarei o feedback para melhorar suas revisões.
Original comment in English

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rnarciso rnarciso deleted the fix-frontend-api-url branch August 15, 2025 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant