question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow for deployment in subdirectory

See original GitHub issue

Is your feature request related to a problem? Please describe.

Currently the app assumes to be deployed on a separate (sub)domain. For the BTCPay Server integration I’d like to use our existing FE proxy (nginx) and certificates to provide an easier setup for the user. I imaging deploying the LiT app in a subdirectory of the existing BTCPay domain, like mybtcpay.com/lit/.

Right now the asset and API requests target the root /, whereas we would need to have them prefixed with /lit/.

Describe the solution you’d like

I started looking into this a bit and found the option of setting the homepage option for create-react-app. By using "homepage": "." as a setting the build uses a relative URL for the asset references, which would solve that part. I’m unsure though whether or not this also works for the API calls. Before proceeding on that front I wanted to inquire if this feature would be wanted.

Describe alternatives you’ve considered

I’ve started using nginx sub_filter directives in our setup to rewrite certain URLs, but this is error prone and brittle.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
jamaljsrcommented, Sep 2, 2021

For the asset paths I’ve found nginx sub_filters as a workaround, though these might be rather easy to eliminate via the homepage option. From what I’ve seen this option would not have a negative side effect for the app.

Frontend-wise the paths switch to the root paths (e.g. /loop/ instead of /lit/loop/) on navigation. This might be solvable by setting the PUBLIC_URL as Oliver suggested.

I believe that setting PUBLIC_URL would help solve both of these issues, but you’d also need a code change for the second one. The magic-string paths specified in the Routes.tsx and appView.ts would also need to be updated to include the PUBLIC_URL env value. I haven’t tested myself but this seems doable.

1reaction
guggerocommented, Aug 25, 2021

there are other apps using the gRPC API as well, which this might interfere with.

No, that’s what the map at the beginning is for. Only LiT makes calls with Content-Type: application/grpc-web+proto while any other, normal, gRPC traffic will have Content-Type: application/grpc. So the requests will be forwarded either to LiT or to lnd depending on whether they come from LiT or not.

The API requests should also use relative paths or the base path of the app should be set on startup/runtime

gRPC doesn’t support relative paths for RPC requests. So this might not even be possible with the library we use.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to deploy a React app to a subdirectory | by Scott Vinkle
1. Set the basename. Setting the basename attribute on the <Router /> component tells React Router that the app will be served from...
Read more >
How to deploy a react app to a subdirectory - Full Stack Tutorials
Deploy a React App to a subdirectory - Step by Step Guide. · 1. Define App Homepage. In package.json add homepage like below...
Read more >
How to Deploy a React App to a Subdirectory - Scott Vinkle
1. Set the basename · 2. Set the app homepage · 3. Update the Routes · 4. Update the Links.
Read more >
Deploying React (Router) app to the subfolder on server
This is the best approach if your subfolder name changes (for example, if folder name is a build version). But you'll have /#/...
Read more >
How to bundle a React app to a subdirectory on a server?
publicPath in your webpack config to tell webpack the subdirectory your assets will be deployed to: output: { path: 'build', publicPath: "/vensa/", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found