Skip to content

[Bug]: Api requests don't use baseUrl #1041

@haylibi

Description

@haylibi

Describe the Bug

Overview

When configuring the application with a BASE_URL (e.g., running behind a reverse proxy like Traefik or Nginx with a path prefix), the frontend assets load correctly, but the internal API calls fail.

The API client seems to default to the root root (/) rather than appending the configured baseUrl.

To Reproduce

  1. Deploy the application using Docker.
  2. Set the environment variable BASE_URL (or equivalent config) to /my-custom-path.
  3. Open the web interface at http://domain.com/my-custom-path.
  4. The UI loads, but data tables (Logs, etc.) are empty or show errors.
  5. Check the Browser DevTools > Network Tab.

Expected behavior

API requests should be sent to: http://domain.com/my-custom-path/api/...

Actual behavior

API requests are being sent to: http://domain.com/api/... (resulting in 404s).

Possible Fix

I noticed the QbitManageApp already exposes a setBaseUrl method, but it is not being utilized in the initialization logic for the api calls.

Similar to app.js implementation, I believe the fix is to call this setter when initializing the class in:

I went ahead and applied this change on this fork and the results were successful (no more errors, and scheduler/log tab on the UI match the expectation)

// Example of the fix I applied:
this.api = new API();
this.api.setBaseUrl(config.baseUrl); // <-- Added this line

Environment

  • Deployment: Docker / Docker Compose
  • Reverse Proxy: Traefik
  • Browser: Chrome/Firefox

Config

# 1. Connection (Gluetun)
qbt:
  host: <MYHOST>
  user: <USERNAME>
  pass: <PASSWORD>

# Add this right at the top or under the 'qbt' section
directory:
  # This must match the internal path in your docker-compose volumes
  root_dir: /data/torrents
  # Where your .torrent files are (the /qbittorrent volume in your compose)
  remote_dir: /qbittorrent

# 2. The "Mandatory" Tracker Section (Fixes the 500 error)
  orphaned_dir: /data/torrents/orphaned_data
  recycle_bin: /data/torrents/.RecycleBin
  torrents_dir:
tracker:
  default:
    tag: managed-by-qbm
cat:
  default: /data/torrents

# 4. Your Sharing Logic
share_limits:
  default:
    categories:
    - default
    max_ratio: 3
    max_seeding_time: 1440
    action: remove
    cleanup: true
    priority: 999

settings:
  force_auto_tmm: false
  tracker_error_tag: issue
  nohardlinks_tag: noHL
  stalled_tag: stalledDL
  share_limits_tag: ~share_limit
  share_limits_min_seeding_time_tag: MinSeedTimeNotReached
  share_limits_min_num_seeds_tag: MinSeedsNotMet
  share_limits_last_active_tag: LastActiveLimitNotReached
  cat_filter_completed: true
  share_limits_filter_completed: true
  tag_nohardlinks_filter_completed: true
  rem_unregistered_filter_completed: false
  cat_update_all: true
  disable_qbt_default_share_limits: true
  tag_stalled_torrents: true
  rem_unregistered_grace_minutes: 10
  rem_unregistered_max_torrents: 10

  private_tag:
  force_auto_tmm_ignore_tags: []
  rem_unregistered_ignore_list: []
webhooks:
  error:
  run_start:
  run_end:
  function:
    tag_tracker_error:
    share_limits:

recyclebin:
  enabled: true
  save_torrents: false
  split_by_category: false

  empty_after_x_days:
orphaned:
  max_orphaned_files_to_delete: 50
  min_file_age_minutes: 0
  empty_after_x_days:
  exclude_patterns:

Logs

https://gist.github.com/haylibi/a8c00543e53bd2704586ee15b555580c

Screenshots

Developer Console (Firefox)

Image

Logs Tab (UI)

Image

Scheduler Tab (UI)

Note: the 404 comes from clicking on Save Schedule --> The API call fails to post due to baseURL

Image

Installation

Docker

Version Number

4.6.5

What branch are you on?

master

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingstatus:added-to-developFeature Request or Bug Fix is in Develop

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions