Skip to content

Allow base path changes #185

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

Closed
wants to merge 1 commit into from
Closed

Conversation

micsthepick
Copy link

I haven't had a chance to fully smoke test this, but it seemingly works, apart from connectivity issues.

@Sean-Der
Copy link
Collaborator

Do you have a proxy in front of broadcast box? Is it possible to rewrite the URLs in that?

The network test would still work also. It should hit Broadcast Box instead of proxy.

If we can't make it work I would love to land the PR! I just want to push off complexity (if possible)

@micsthepick
Copy link
Author

Nginx may rewrite in the forwards direction, but I wouldn't be able to host any other app at /api

@mauveferret
Copy link

Nginx may rewrite in the forwards direction, but I wouldn't be able to host any other app at /api

Hello. I'v tried to run broadcast-box with your commit with BASE_PATH="test123" and BASE_PATH="" in .env.production. In both cases i'v got "404 page not found" text with black blank screen in browser. In the first case with address "http://my_ip:8080/test123" and in the second with "http://my_ip:8080/". By checkout to previous version, removing BASE_PATH and rebuilding the project i'm getting normal broadcast-box web page, which works fine.

Additionally if i enable NETWORK_TEST_ON_START, i get the following on start:

mephist@cms:~/broadcast-box-BaseUrl$ go run .
2025/04/10 21:29:01 Loading `.env.production`
NETWORK_TEST_ON_START is enabled. If the test fails Broadcast Box will exit.
See the README for how to debug or disable NETWORK_TEST_ON_START
2025/04/10 21:29:01 Running HTTP Server at `:8080`
panic: invalid NewRequest arguments; parse "test123/api/whip": invalid URI for request

goroutine 6 [running]:
net/http/httptest.NewRequest({0xa93291?, 0xc00003c262?}, {0xc0001b1e38, 0x10}, {0xb67380?, 0xc000218a60?})
        /usr/local/go/src/net/http/httptest/httptest.go:46 +0x574
github.com/glimesh/broadcast-box/internal/networktest.Run(0xad7718)
        /home/mephist/broadcast-box-BaseUrl/internal/networktest/networktest.go:68 +0x336
main.main.func2()
        /home/mephist/broadcast-box-BaseUrl/main.go:248 +0x33
created by main.main
        /home/mephist/broadcast-box-BaseUrl/main.go:245 +0x1ea
exit status 2
mephist@cms:~/broadcast-box-BaseUrl$

Can you advise what I'm doing wrong?

P.S. My env file when error occurs:

HTTP_ADDRESS=":8080"
#REACT_APP_API_PATH="/test123/api"
BASE_PATH="test123"
NETWORK_TEST_ON_START=true

@micsthepick
Copy link
Author

I lost interest in completing this draft for a while, but @mauveferret does any other path apart from the base URL also error?

@mauveferret
Copy link

I lost interest in completing this draft for a while, but @mauveferret does any other path apart from the base URL also error?

Frankly speaking, I also lost interest after solving my task with the restreamer project. However, with it I also initially encountered the problem that not all links were redirected correctly. I was able to solve the problem by writing an additional redirect in nginx. The same recipe helped here with broadcast-box. Thus, I successfully launched your version of a broadcast box with the following .env.production file:

HTTP_ADDRESS=":8085"
ENABLE_HTTP_REDIRECT=
REACT_APP_API_PATH="/test123/api"
BASE_PATH="/test123"

So, it turned out that the path needed to be changed also in REACT_APP_API_PATH variable. Additionally, i noticed variable PUBLIC_URL in the source code, which is not mentioned in docs, but i have not succeeded with it. It seems this variable influences logs during building: "The project was built assuming it is hosted at PUBLIC_URL". So by default i see "The project was built assuming it is hosted at /.".

Then, my nginx config for broadcast-box looks as:

    location /test123/ {
        proxy_http_version 1.1;
        proxy_pass http://192.168.87.7:8085/;
        proxy_redirect http://192.168.87.7:8085/test123/ /test123/;

    }

    location /static/ {
        rewrite ^/static/(.*)$ /test123/static/$1 permanent;
    }

So, my initial problem with launching your rep was due to broken links like "my_external_url/static/js/..." instead of "my_external_url/test123/static/js/...", as was seen in web browser console. After adding the block for static in nginx config everything worked fine, so i could publish stream and watch it by "https://my_external_url/test123/some_streaming_key".

Unfortunately, I'm a complete lamer in this, but perhaps some paths in the js sources are hardcoded? Or am I initially writing the config incorrectly? However, i can say that with the settings provided it works fine in chrome and edge browser. Additionally, i noticed that it does not work in firefox and android.

@Sean-Der
Copy link
Collaborator

If this would help anyone else I would be happy to merge/bring this PR back!

Maybe we could do this at runtime though? Detect the suffix of the request. It would be nice when setting up Broadcast Box to do the least amount of work possible.

@Sean-Der Sean-Der closed this Jul 29, 2025
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.

3 participants