lowcoder icon indicating copy to clipboard operation
lowcoder copied to clipboard

[Feat] - Client appliaction routes constructed considering the BASE_URL

Open nachogrj opened this issue 1 year ago • 9 comments
trafficstars

Proposed changes

We wanted to publish the app through a reverse proxy and changing the configuration variables (both when using the already built docker image or building the code ourselves) wasn't taking effect. We detected that the BASE_URL wasn't being used when defining the rest of the routes, nor for the bundleLoader URL.

Types of changes

What types of changes does your code introduce to Lowcoder?
Put an x in the boxes that apply.

  • [ X] Bugfix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Documentation Update (if none of the other choices apply)

Checklist

You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
Put an x in the boxes that apply.

  • [ ] Lint and unit tests pass locally with my changes
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added necessary documentation (if appropriate)
  • [ ] Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc.

nachogrj avatar Jun 18 '24 13:06 nachogrj

Deploy request for lowcoder-cloud pending review.

Visit the deploys page to approve it

Name Link
Latest commit 489ab1275cb55039a9c62107eea1224f9b96149c

netlify[bot] avatar Jun 18 '24 13:06 netlify[bot]

Hello @nachogrj - you will smile, cause in the branch https://github.com/lowcoder-org/lowcoder/tree/feature-sub-path - we tried pretty much exactly this. We need to check the solution for the plugin loader. It could have cross effects.

Question... How about we join forces - and wor together in the feature-sub-path about this topic?

FalkWolsky avatar Jun 19 '24 09:06 FalkWolsky

Sure @FalkWolsky, the only thing is that I don't see how these changes may affect the plugin loader since the actual routes for routing requests (and loading files) are handled in the Nginx configuration (I am not familiar with how this backend works).

nachogrj avatar Jun 19 '24 13:06 nachogrj

Let us ask a small thing... By introducing the BASE_URL - what is the actual goal behind? We do - which is the reason we ask - have a very old ticket and need to run lowcoder as subpath. So not app.yoururl.com but yoururl.com/lowcoder/...

But this is tricky... Cause BASE_URL would be only used at Build time. Also, static resources are not affected by it. This counts for libraries (js), images and CSS.

Is "subpath" the goal of your PR?

FalkWolsky avatar Jun 21 '24 14:06 FalkWolsky

As Falk mentioned, adding BASE_URL into the code is not enough in our case. The code is compiled into static files, so once it is generated, the variable will not help you, because all links in html/css/js will be generated with whatever it was set to during compile time.

ludomikula avatar Jun 24 '24 12:06 ludomikula

@FalkWolsky Yes, our intention is to publish the app (as a sub-path) using a reverse proxy. @ludomikula yes I'm awared of it, would it be possible to do it by injecting the configuration through an ".env" (when building the Dockerfile or running the docker-compose) file and checking the values from the application using "window.env.BASE_URL" at runtime (or something similar). Does it seem feasible?

nachogrj avatar Jun 25 '24 12:06 nachogrj

Building the frontend image on startup would take really long time. It's quite a heavy process. What might be doable, is to generate a placeholder in the static files, something like LOWCODER_BASE_URL which then we could rewrite in nginx to the configured value.

ludomikula avatar Jun 26 '24 15:06 ludomikula

@ludomikula Sorry maybe I didn't express myself correctly, I said building the docker image but I was referring exclusively to its execution (running the container). I was thinking of getting the value of the environment variable at runtime, not at build time. Anyway, the problem we run into is the navigation from the client application, for which, the URLs do not contain the prefix that would allow us to distinguish for which application exactly I have to rewrite the URL (I'm thinking of a reverse proxy in front of multiple applications, not just the lowcoder ecosystem). Maybe the only way is to add a fixed block in the URL to be able to detect that a rewrite is to be performed. Is that what you meant?

nachogrj avatar Jun 27 '24 08:06 nachogrj

@nachogrj yes, that's what I meant. Currently am not aware of another solution.

ludomikula avatar Jul 03 '24 11:07 ludomikula