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

Support for custom URL roots #67

Open
ivanbakel opened this issue Jun 21, 2021 · 3 comments
Open

Support for custom URL roots #67

ivanbakel opened this issue Jun 21, 2021 · 3 comments

Comments

@ivanbakel
Copy link

I'm looking into using odd-jobs to replace a home-spun job queue implementation. The web UI is really useful, but I would like to put it behind a subpath on an auth-protected domain which I use for all my dev UIs, so that I can still access it remotely.

Currently, I using a reverse-proxy to do that - so the web UI is served on a URL like

https://my.dev.domain/jobs/

and that routes to

http://127.0.0.1:<odd-jobs-port>

However, the UI doesn't currently really support this. All of the static assets and links are broken, since they expect to be served from the URL root /, rather than the /jobs/ path. It would be great if odd-jobs would support custom URL roots, so I could use it in the above way.

@saurabhnanda
Copy link
Owner

@ivanbakel I believe the code already supports this. Please take a look at the following function -

mkEnv :: (MonadIO m) => Config -> (Text -> Text) -> m Env
mkEnv cfg@Config{..} linksFn = do
allJobTypes <- fetchAllJobTypes cfg
allJobRunners <- fetchAllJobRunners cfg
envJobTypesRef <- newIORef allJobTypes
envJobRunnersRef <- newIORef allJobRunners
let envRoutes = routes linksFn
The second argument is a function that allows you to transform the links generated by the web UI to whatever you want. This "hook" was added specifically for your use-case.

Are you starting the web UI via the default command-line? We can probably add another flag --web-ui-root-path to make this easier without having to write custom code.

@ivanbakel
Copy link
Author

Good to know, thanks! I am using the default command-line settings to start the web UI, so a flag would be really useful. I'll make a PR to support doing that.

@saurabhnanda
Copy link
Owner

@ivanbakel before you work on the PR, please take a look at #76 -- this might make your PR easier.

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

No branches or pull requests

2 participants