Skip to content
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

refactor(http): BaseUrl handling #1298

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

refactor(http): BaseUrl handling #1298

wants to merge 8 commits into from

Conversation

kaiserbh
Copy link
Collaborator

@kaiserbh kaiserbh commented Dec 4, 2023

Hopefully closes #1166, I am sure this is a breaking change so do test it thoroughly.
By breaking change I mean maybe proxy level, people might have to update their proxy configuration.

  • This fix also addresses the previously required rewrite on the proxy level for baseUrl.

I only tested it with caddy with below config

localhost /autobrr {
    reverse_proxy :7474
}

sse seem to work fine and not seeing any errors.

Anyway do test it.

Since that's where the api endpoint is that way we set it to the root domain, we can't set it to the subfolder since the api is called directly now and not using the baseUrl.
When user for example is in `/autobrr` and hit reload it should just return the index.html.
Remove the trailing `/`, now base url is set to /autobrr aligned with other arrs.
I don't think we need separate router, but I didn't test it, so feel free to test it and see if it works without the separate router, the whole point was to make sure that it's not prefixed with baseUrl and I noticed that it was being called in the frontend `APIClients.ts`. So yea just check if it works without it then keep the old one.

Also removed the index since it was zombie code not being used anywhere.
Comment on lines +22 to +28
// Dynamically determine the base URL
window.BASE_URL = '{{.BaseUrl}}';

// Update the base tag dynamically
const base = document.createElement('base');
base.href = window.BASE_URL;
document.head.appendChild(base);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we could move this block to bellow where the window.APP.baseUrl is being defined already, than we can use that variable to base.href

base.href = window.APP.baseUrl;

@zze0s zze0s changed the title Fix: Correct Handling of BaseUrl. refactor(http): BaseUrl handling Dec 25, 2023
@zze0s zze0s added web backend Backend api Backend API labels Dec 25, 2023
@@ -62,7 +62,7 @@ func (h authHandler) login(w http.ResponseWriter, r *http.Request) {

h.cookieStore.Options.HttpOnly = true
h.cookieStore.Options.SameSite = http.SameSiteLaxMode
h.cookieStore.Options.Path = h.config.BaseURL
h.cookieStore.Options.Path = "/"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should be setting cookieStore to /. A significant amount of our users host on baseurls and this will allow other applications on the machine to read the cookie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Backend API backend Backend web
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not all paths are rewritten to the baseUrl
4 participants