Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

flexibility of port and subpath #337

Open
mamumumam opened this issue Feb 15, 2021 · 5 comments
Open

flexibility of port and subpath #337

mamumumam opened this issue Feb 15, 2021 · 5 comments

Comments

@mamumumam
Copy link

I would like to bind the postfacto ui to "myserver.de:8000/postfacto".

Is there any possibility to do this by changing only small configuration things?

@textbook
Copy link
Contributor

You can configure where the frontend looks for the backend in public/config.js:

https://github.com/pivotal/postfacto/blob/245e0205d676f2e1f1a005cfc89060afe37a9887/web/public/config.js#L13-L14

Note if you're not serving the frontend on the same domain as the backend you'll also need CORS configuration, you can set the CLIENT_ORIGIN environment variable for the Rails app to enable this:

https://github.com/pivotal/postfacto/blob/fc775053346b22e9fadbe9ab863baf94fc1cabad/api/config/environments/production.rb#L124-L131

@mamumumam
Copy link
Author

I did the change in the confiig.js and rebuilt the Docker image. Unfortunately it still asks for /api and /cable instead of /postfacto/api and /postfacto/cable. Any additional hint?

@mamumumam
Copy link
Author

Meanwhile could figure out why the Docker build doesn't work. The config.js is generated by the entrypoint. You need to adapt the entrypoint to do the changes suggested above. But even then it still doesn't work.

I also tried to modify the package.json with "homepage" tag to move the frontend. But still postfacto doesn`t work. I also recognized that the admin part is another story as it shows different paths as the main app.

So, the question remains: Is it possible to move backend and frontend to a different subpath?
Is this flexibility already given by configuration or maybe just with an high effort because of multiple absolute paths?

@textbook
Copy link
Contributor

That's right, if you're using the Docker build the config.js is provided by the entrypoint script:

https://github.com/pivotal/postfacto/blob/245e0205d676f2e1f1a005cfc89060afe37a9887/docker/release/entrypoint#L33-L52

Changes made in there should be reflected in the response when the React app makes a request for the config.js, what do you see for that request?

And yes, the admin UI is still at wherever.backend.is/served/admin because that's the ActiveAdmin panel served by the Rails app, it's not a separate React app like the client UI. To configure that see e.g. https://stackoverflow.com/q/11691169/3001761.

@mamumumam
Copy link
Author

mamumumam commented Feb 19, 2021

I did several approaches meanwhile but unfortunately without final success.

Here is what I've changed so far:

  1. Added to api/config/environments/production.rb

     config.relative_url_root = '/postfacto'
  2. Adapted config.ru

    map Rails.application.config.relative_url_root || "/" do
        run Rails.application
    end
  3. Modified api/config/routes.rb

    scope '/postfacto/api' do
  4. adapted entrypoint as suggested above

  5. added to web/package.json

    "homepage": "/postfacto/",

By doing so I now receive for all calls in my browser a status 200, which should be fine, but the page unfortunately states "Oh no! It's broken".
Looks like now the application is crashing, but I can't see any errors in the logfiles.

Do you maybe have further suggestions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants