coder / modules

A collection of Terraform Modules to extend Coder templates.
https://registry.coder.com
Apache License 2.0
33 stars 33 forks source link

bug(filebrowser): Base URL Configuration Issue in FileBrowser Module #309

Closed link-webcreations closed 1 month ago

link-webcreations commented 1 month ago

Base URL Configuration Issue in FileBrowser Module

Problem Description

There's an issue in the FileBrowser module version 1.0.19, specifically in the filebrowser/run.sh#L21 script. The script attempts to customize the server Base URL before starting the server in the background. However, this customization only works when the database is located at the default path, ~/filebrowser.db.

If the database location has been modified (e.g.: database_path = "/home/coder/.filebrowser/filebrowser.db"), the script tries to update the default database location, resulting in no changes. Consequently, the Base URL remains empty.

Current Behavior

# Current implementation
filebrowser config set --baseurl "${SERVER_BASE_PATH}" > ${LOG_PATH} 2>&1

This line only works correctly with the default database location.

Proposed Solution

To address this issue, we can leverage the existing mechanism used for starting the server. Here's the proposed change:

# set baseurl to be able to run if sudomain=false; if subdomain=true the SERVER_BASE_PATH value will be ""
-filebrowser config set --baseurl "${SERVER_BASE_PATH}" > ${LOG_PATH} 2>&1
+filebrowser config set --baseurl "${SERVER_BASE_PATH}"$${DB_FLAG} > ${LOG_PATH} 2>&1

This modification could ensures that the Base URL is correctly set regardless of the database location (to be tested).

jeehoonkang commented 1 month ago

@matifali it seems it's a genuine bug. I'm experiencing the same symptom :)

matifali commented 1 month ago

Thank you, @jeehoonkang. I think #320 will fix this.

matifali commented 1 month ago

Hi @jeehoonkang Could you test the updated module using

module "filebrowser" {
  source        = "git::https://github.com/yandolfat/modules.git//filebrowser?ref=patches/filebrowser"
  agent_id      = coder_agent.example.id
  agent_name    = "main"
  subdomain     = false
  database_path = ".config/filebrowser.db"
}

Let me know if that works and I will merge the PR and cut a new release.