Skip to content

Fix for frontend app trying to load /config.json from the root path #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

fbradyirl
Copy link

@fbradyirl fbradyirl commented May 2, 2025

Description

The core issue now here that the frontend app in StreamMaster is trying to load /config.json from the root path, which does not work under Home Assistant’s Ingress, where paths are prefixed (like /api/ingress/slug/).

image

🧠 Root Problem:

This code in settings.ts is not ingress-aware:

request.open("GET", "/config.json", false); // hardcoded path

So in Ingress, it tries to request:

https://<ha-host>/config.json → ❌ 404

Whereas it needs:

https://<ha-host>/api/ingress/slug/editor/config.json → ✅ if served there

Issues (Fixed or Closed)

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

Dependencies

  • New dependencies added
  • System requirements changed

Checklist

  • I have followed the Conventional Commits naming convention
  • My branch is up to date with the main branch (rebased)
  • My code follows the style guidelines and existing patterns of this project
  • I have performed a self-review of my own code
  • I have commented complex logic
  • I have added tests (if applicable)
  • All tests are passing
  • I have updated documentation as needed

@fbradyirl
Copy link
Author

Seems like a GitHub token issue in the PR build.

@carlreid
Copy link
Owner

carlreid commented May 3, 2025

Seems like a GitHub token issue in the PR build.

Yeh, I didn't get around to fixing it yet as there hasn't been many PRs that aren't from myself.

is trying to load /config.json from the root path, which does not work under Home Assistant’s Ingress, where paths are prefixed (like /api/ingress/slug/).

Definitely not ideal. Though I am not sure if the proposed changes here will work all the time? For instance, loading directly into different client side paths like /settings, /editor/streams would resolve the config.json path differently I think?

I'm finding it difficult to find a reliable way to find the path. Though given what config.json is being used for, I wonder if it can be avoided entirely. So long as there was a way to dynamically set the values to support the current docker entrypoint logic.

I have followed the Conventional Commits naming convention

The commits don't follow the conventions. Please do follow them, as the release logic depends on the conventions to understand what kind of version bump is required.

@carlreid
Copy link
Owner

carlreid commented May 3, 2025

I've added a new commit, fix: Load config relativly to module path, which I believe should be a more ideal approach for loading the config.json. Would be great if you could give it a try 🙏

@fbradyirl
Copy link
Author

The commits don't follow the conventions. Please do follow them, as the release logic depends on the conventions to understand what kind of version bump is required.

Will do.

Would be great if you could give it a try 🙏

Thanks for this. Could you tell me what Docker build command you use locally to build? I couldn't figure it out exactly from looking at the various workflow files.

@carlreid
Copy link
Owner

carlreid commented May 3, 2025

Could you tell me what Docker build command you use locally to build?

I don't really bother with Docker. For this, I just ran the Web UI with npm run dev since it's only a front-end issue. If I needed the backend, I'd also run the API with Visual Studio.

For testing these changess, I did a npm run build and ran a simple HTTP server on the /dist/ folder to test it loaded from a root based URL (e.g. http://localhost:8000/) and then also ran the same HTTP server from the parent directory of /dist/ meaning I had to load the site from http://localhost:8000/dist/, similar to the path based hosting you're looking into. I could see that on the /dist/ path it sill loaded the config.json correctly based on the import.meta.url URL.

Now the PR is open here and built/published, you can also test the changes with the image ghcr.io/carlreid/streammaster:pr-116.

@fbradyirl
Copy link
Author

fbradyirl commented May 3, 2025

Thanks for the tips. Im using that image now:

https://github.com/fbradyirl/streammaster-addon/actions/runs/14810883099/job/41585402632#step:6:389

image

but still see the config 404 from root:

Screenshot 2025-05-03 at 13 42 51

@fbradyirl
Copy link
Author

Not sure if it helps but here is the log:

Running with root user (PUID=0)
Running with root group (PGID=0)
Configuration:
--------------
HOST:
  Default Port: 7095
  Default SSL Port: 7096
PGADMIN:
  Platform Type: debian
  Setup Email: disabled
  Setup Password: ********
POSTGRES:
  User: postgres
  Password: ********
  DB Name: postgres
  Host: homeassistant.local
  Is DB Local: 0
  Data Directory: /config/DB
  Set Perms: 0
OS:
  User: 0 Group: 0
  User: postgres Group: postgres
  UID: 100 GID: 102
PostgreSQL is ready on homeassistant.local:5432
Postgres is up
No backup files found in /config/Restore.
Running as root
Using settings file /config/settings.json
Creating Directories
Using settings file /config/settings.json
Using settings file /config/Settings/commandprofiles.json
Using settings file /config/Settings/customLogos.json
Using settings file /config/Settings/outputprofiles.json
Using settings file /config/Settings/sdsettings.json
warn: Microsoft.EntityFrameworkCore.Model.Validation[10400]
      Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
info: StreamMaster.API.Services.PostStartup[0]
      Stream Master is starting.
warn: Microsoft.AspNetCore.Hosting.Diagnostics[15]
      Overriding HTTP_PORTS '8080' and HTTPS_PORTS ''. Binding to values defined by URLS instead 'http://0.0.0.0:7095'.
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://0.0.0.0:7095
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /app
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Current migration: 20250217190832_M3UFileId
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Pending migrations: 
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 001_channelgroup_indexes.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 002_create_or_update_smstreams_and_channels.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 003_delete_sm_channels.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 004_epgfile_indexes.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 005_get_unique_smchannel_name.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 006_smchannel_indexes.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 007_smchannelstreamlink_indexes.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 008_smstream_indexes.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 009_streamgroup_indexes.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 010_streamgroupsmchannellink_indexes.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 011_update_channel_group_counts.sql
info: StreamMaster.Infrastructure.EF.PGSQL.PGSQLRepositoryContext[0]
      Executing script: 012_migrate_new_channel_ids.sql
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added EPGSync to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got EPGSync from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting EPGSync
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added ScanForTvLogos to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added ScanDirectoryForEPGFiles to Queue
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: EPGSync
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added ScanForCustomPlayLists to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added ScanDirectoryForM3UFiles to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added CacheChannelLogos to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added CacheStreamLogos to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added CreateSTRMFiles to Queue
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: EPGSync
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished EPGSync
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got ScanForTvLogos from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting ScanForTvLogos
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: ScanForTvLogos
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: ScanForTvLogos
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished ScanForTvLogos
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got ScanDirectoryForEPGFiles from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting ScanDirectoryForEPGFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: ScanDirectoryForEPGFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: ScanDirectoryForEPGFiles
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished ScanDirectoryForEPGFiles
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got ScanForCustomPlayLists from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting ScanForCustomPlayLists
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: ScanForCustomPlayLists
info: StreamMaster.Infrastructure.EF.Repositories.SMChannelsRepository[0]
      Bulk update 0 channels in 6ms.
info: StreamMaster.Infrastructure.EF.Repositories.SMChannelsRepository[0]
      Total elapsed time: 683ms.
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: ScanForCustomPlayLists
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished ScanForCustomPlayLists
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got ScanDirectoryForM3UFiles from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting ScanDirectoryForM3UFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: ScanDirectoryForM3UFiles
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added ProcessM3UFile to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added ProcessM3UFile to Queue
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: ScanDirectoryForM3UFiles
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished ScanDirectoryForM3UFiles
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got CacheChannelLogos from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting CacheChannelLogos
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: CacheChannelLogos
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: CacheChannelLogos
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished CacheChannelLogos
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got CacheStreamLogos from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting CacheStreamLogos
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: CacheStreamLogos
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: CacheStreamLogos
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished CacheStreamLogos
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got CreateSTRMFiles from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got ProcessM3UFile from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting ProcessM3UFile
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: ProcessM3UFile
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added CreateSTRMFiles to Queue
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Processed M3U 'Z2U UK Channels' successfully
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: ProcessM3UFile
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished ProcessM3UFile
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got ProcessM3UFile from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting ProcessM3UFile
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: ProcessM3UFile
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added CreateSTRMFiles to Queue
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Processed M3U 'uk sport movies Z2U' successfully
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: ProcessM3UFile
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished ProcessM3UFile
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got CreateSTRMFiles from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got CreateSTRMFiles from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished CreateSTRMFiles
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added CacheEPGChannelLogos to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got CacheEPGChannelLogos from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting CacheEPGChannelLogos
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: CacheEPGChannelLogos
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: CacheEPGChannelLogos
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished CacheEPGChannelLogos
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Added SetIsSystemReady to Queue
info: StreamMaster.Infrastructure.Services.QueueService.BackgroundTaskQueue[0]
      Got SetIsSystemReady from Queue
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Starting SetIsSystemReady
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Starting task: SetIsSystemReady
info: StreamMaster.Application.Statistics.Commands.SetIsSystemReadyRequest[0]
      System build 0.13.0
info: StreamMaster.Infrastructure.Services.MessageService[0]
      Finished task: SetIsSystemReady
info: StreamMaster.Infrastructure.Services.QueueService.QueuedHostedService[0]
      Finished SetIsSystemReady

@fbradyirl
Copy link
Author

From testing my original commit, it did load the config OK but hit a problem further onwards as you suspected.

image

404 for /streammasterhub/negotiate?negotiateVersion=1

image

@carlreid
Copy link
Owner

carlreid commented May 3, 2025

Not sure if it helps but here is the log:

It's web client side, so the logs should appear in the console output within the browser. However by default, only error level logs are output in production builds. I just added a couple of console.log which I think should survive a build, which ought to help diagnose what the basePath is coming out to be.

@fbradyirl
Copy link
Author

Huh im not seeing those new logs at all in the console (even when I directly navigate to the app outside of the HA UI)...

image

Inside HA:
Screenshot 2025-05-03 at 18 52 48

Sorry Im a backend service dev and never ventured to frontend or any .Net stuff before so im a bit clueless on this.

@carlreid carlreid force-pushed the main branch 2 times, most recently from d6b8247 to 6fbe620 Compare May 3, 2025 18:37
@carlreid
Copy link
Owner

carlreid commented May 3, 2025

Sorry Im a backend service dev and never ventured to frontend or any .Net stuff before so im a bit clueless on this.

No problem, appreciate the effort 👍

I've modified the last commit to just force the Logger to output up down to debug logs also in a production env. That I think should make them all appear, as well as using the Logger directly for the additional log messages

You may also wish to use "Persist Logs" option in the Dev Console -> Console settings, in case a redirect happens where the logs wouldn't be then seen from the ConfigLoader.
image

Edit:
The logs ought to look like this (example from running a simple web server locally, where root is "dist" folder):
image

@fbradyirl
Copy link
Author

Thanks for this.

Im still not seeing them im afraid. I think HA is doing something funky to intercept them maybe?

Failed to load ‘https://<redacted.domain>/api/hassio/addons/e517628b_streammaster/logs/follow’. A ServiceWorker intercepted the request and encountered an unexpected error.

@fbradyirl
Copy link
Author

Even running in Docker on my Mac I dont see the logs.

image

Using compose:

services:
  streammaster:
    image: ghcr.io/carlreid/streammaster:pr-116
    container_name: streammaster
    ports:
      - 7095:7095
    restart: unless-stopped
    volumes:
      - ~/streammaster:/config
      - ~/streammaster/tv-logos:/config/tv-logos

@fbradyirl
Copy link
Author

Ok I have it working with the latest commit now. Also I can see those Console logs:

image

There still are some 404's but im not sure what the impact is from these:

http://10.66.77.4:8123/images/streammaster_logo.png

image

and a bunch more at the end:

image

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.

Bug: Frontend app trying to load /config.json from the root path
2 participants