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

Allow to configure the prefix path #80

Closed
edupo opened this issue Dec 2, 2020 · 10 comments
Closed

Allow to configure the prefix path #80

edupo opened this issue Dec 2, 2020 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed javascript Things concerning Javascript code

Comments

@edupo
Copy link

edupo commented Dec 2, 2020

I tried to configure docat after my other Nginx server where Jenkins is running. The root path of the server is reserved also.

It would be great to allow to set somewhere the prefix path of the app so it would be possible to use it from a different path:

myserver/docat/#
myserver/docat/doc/myproject/latest

The backend works without issue, but the web interface has troubles dealing with that. You can enable part of the frontend by rebuilding the container while modifying the vue.config.js to contain publicPath: '/docat/' but that does not make it entirely work.

@fliiiix fliiiix added the bug Something isn't working label Jun 17, 2021
@fliiiix fliiiix added help wanted Extra attention is needed javascript Things concerning Javascript code labels Sep 30, 2021
@palto42
Copy link

palto42 commented Dec 31, 2022

For my local environment I can't use a dedicated sub-domain for docat, so I would like to reverse-proxy it on a sub-path. Adding such prefix path option would be really great!

@reglim
Copy link
Contributor

reglim commented Jan 4, 2023

@edupo @palto42

I tried doing this, but I didn't manage to get it to work either.

What I tried:

  1. Add basename to the hashrouter:
    This didn't work because the uri would then be /#/docat/...
  2. Switch to browser router and add basename there:
    This didn't work because it wouldn't recognize the hashtag we have in the url for backwards-compatability:
         <Router basename="/test/#"> is not able to match the URL "/test/#/" because it does not start with the basename, so the <Router> won't render anything.
    
  3. I also tried replacing the hashtag with it's url encoded counterpart, but that didn't work either, because it didn't interpret the url encoded hashtag as a hashtag
  4. Finally I tried adding it in the nginx config, but I couldn't get it to work there either and it wouldn't help you locally anyway.

If anyone has another idea on how to fix that, you're welcome to try.

Also here are the sources I followed:
https://www.kindacode.com/article/how-to-change-the-base-path-in-react/
https://serverfault.com/questions/853559/nginx-place-a-prefix-in-my-url
https://stackoverflow.com/questions/70519315/router-basename-is-not-able-to-match-the-url-because-it-does-not-start-with-the
remix-run/react-router#8460 (comment)
remix-run/react-router#8459

@palto42
Copy link

palto42 commented Jan 4, 2023

@reglim thanks for your effort to try and find a solution.
Unfortunately I have no experience with react, so can't help much.

I found this page about sub-site topic, but not sure if it provides any new ideas: https://muffinman.io/blog/react-router-subfolder-on-server/

What exactly did you try in #4 with nginx config? The above page suggests that the HashRouter should work (without specifying basename) if the app is deployed in a subfolder of the web server.

@reglim
Copy link
Contributor

reglim commented Jan 17, 2023

@palto42

Thanks for the article, I'll try that out and get back to you.

I tried something like this, though I'm not sure that this is even remotely correct:

    location /docat/doc {
        root /var/docat;
    }

    location /docat/api {
        client_max_body_size 100M;
        proxy_pass http://python_backend;
    }

    location /docat {
    }

@palto42
Copy link

palto42 commented Jan 17, 2023

@reglim Thanks, this is what I also tried for the first option in the article I shared, but didn't work as expected.

reglim added a commit that referenced this issue Jan 18, 2023
You can now add a prefix path for docat (eg. https://domain.com/docat as
the root url).
Just follow the instructions in the readme

fixes: #80
reglim added a commit that referenced this issue Jan 18, 2023
You can now add a prefix path for docat (eg. https://domain.com/docat as
the root url).
Just follow the instructions in the readme

fixes: #80
@reglim
Copy link
Contributor

reglim commented Jan 18, 2023

@palto42 @edupo

Ok, so I managed to get it to work in using a build arg for docat. The exact instructions are in the ReadMe.

I'd be glad if you could try it out and get back to me to tell me whether or not it works properly.
It's a bit janky because we need to rebuild the whole web project, replace the paths in the nginx config and include it in the API.

@palto42
Copy link

palto42 commented Jan 18, 2023

@reglim Thanks for the update, tried it with a docker image built from the new branch as per instructions and configured a reverse proxy on my main nginx for https like below:

    location ^~ /docat/ {
        proxy_pass http://localhost:8000/docat/;
    }

and ... works :)

Initially I missed that I need to configure the package.json and provide the PREFIX_PATH_ARG, somehow I thought that setting the variable would also update the package.json. Not sure if this would be possible somehow.

It could be useful to tag the locally created docker image with the prefix path used, i.e. adding -t docat:prefix_docat to the docker build command.

@reglim
Copy link
Contributor

reglim commented Jan 23, 2023

@palto42

Yes, I tried including the Prefix Path in the package.json, but somehow envsubst didn't work. Anyway, including that would kind of break the compatability with local development, as you would have to have the configuration with an environment variable in there:

"homepage": "$PREFIX_PATH",

I think that this is a rather niche usecase compared to local development, so I think no prefix path is not such a bad default.

Also, I think that tagging the docker image is a good idea. I'll add it to the ReadMe : )

reglim added a commit that referenced this issue Jan 23, 2023
You can now add a prefix path for docat (eg. https://domain.com/docat as
the root url).
Just follow the instructions in the readme

fixes: #80
reglim added a commit that referenced this issue Jan 23, 2023
You can now add a prefix path for docat (eg. https://domain.com/docat as
the root url).
Just follow the instructions in the readme

fixes: #80
reglim added a commit that referenced this issue Jan 23, 2023
You can now add a prefix path for docat (eg. https://domain.com/docat as
the root url).
Just follow the instructions in the readme

fixes: #80
reglim added a commit that referenced this issue Jan 23, 2023
You can now add a prefix path for docat (eg. https://domain.com/docat as
the root url).
Just follow the instructions in the readme

fixes: #80
reglim added a commit that referenced this issue Mar 3, 2023
You can now add a prefix path for docat (eg. https://domain.com/docat as
the root url).
Just follow the instructions in the readme

fixes: #80
reglim added a commit that referenced this issue Mar 6, 2023
You can now add a prefix path for docat (eg. https://domain.com/docat as
the root url).
Just follow the instructions in the readme

fixes: #80
@reglim
Copy link
Contributor

reglim commented Mar 6, 2023

Hi @palto42 @edupo, a quick update.

@randombenj, @fliiiix and I have thought about the Pull Request that is still open, and come to the conclusion that this prefix path option adds complexity to docat that we don't think is necessary for most use cases.
We therefore won't merge the fix that can be found here. As we don't want to maintain two versions of docat, we also won't maintain the fix. If any of you are interested, however, feel free to fork Docat.

@reglim reglim closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2023
@palto42
Copy link

palto42 commented Mar 11, 2023

@RGLim Thanks, I understand your rationale. I will try to avoid prefix path, forking will be too much effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed javascript Things concerning Javascript code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants