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

Add variable to support prefixPath for the cadence web-UI #576

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sachin71p
Copy link

This PR adds new PREFIX_PATH variable to enable hosting cadence-web at some base URL prefix path.

This variable needs to be injected during build time and runtime as well since client code also needs it.

Ex. I can build cadence-web using the command below.

docker build . -f Dockerfile -t cadence-web:1.2.2-b12 --build-arg PREFIX_PATH=/cadence-web

Then I can define environment variable during runtime.

docker run -it -p 8088:8088 -e PREFIX_PATH=/cadence-web cadence-web:1.2.2-b12

If PREFIX_PATH is not defined during build and runtime, cadence-web would be running at / root path by default.

@CLAassistant
Copy link

CLAassistant commented May 23, 2024

CLA assistant check
All committers have signed the CLA.

@sachin71p sachin71p marked this pull request as draft May 23, 2024 19:28
Copy link
Contributor

@Assem-Uber Assem-Uber left a comment

Choose a reason for hiding this comment

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

Also tested the changes and had few extra comments there:

const prefixPath = process.env.PREFIX_PATH;

if (!origin.endsWith(prefixPath)) {
origin = `${origin}${prefixPath}`.replace(/\/$/, '');
Copy link
Contributor

Choose a reason for hiding this comment

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

adding path to origin is misleading, managing the path is more accurate

const app = new Koa();
const appPrefixPath = process.env.PREFIX_PATH || '/'

app.use(mount(appPrefixPath, cadenceWeb.init()));
Copy link
Contributor

Choose a reason for hiding this comment

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

This middleware needs to get added inside server/index and used as part of the app init. The server/index acts as the entrypoint if you are installing cadence-web as a dependency package. (more about it here)

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