Open blcham opened 6 months ago
@shellyear I have added "A/C" to the description of the issue
@blcham It works with dockerization, in order to test that I made a docker build, and used that image in docker-compose.yml for record-manager and tested on localhost:1235. It works on vite dev and build. What do you mean by vite development deployment ?
By vite development deployment
I mean working when running from http://localhost:5174.
@shellyear I merged the initial fix, but there are still issues:
Before your fix, when entering such URL, it navigated to the dashboard page, which is a better solution than showing a white screen. If we do not solve this issue, I would rather revert this fix.
@blcham link to institution "/institution/:id" works on dev, but fails on build
@blcham It makes request, to the institutions/config somehow and can't find the institutionsController in the build after refresh (err 404)
That means the path to config.js
is wrongly set.
@blcham It works with dockerization, when I set a "base" as "/record-manager/", but for dev and build it should be not explicitly set (defautl base is "/")
How deployment works:
base
attribute which is used to prefix all references from index.html. It can be imagined as substituting ${base} variable into index.html file as the following:
...
<script type="module" src="${base}config.js"></script>
<script type="module" crossorigin src="${base}assets/index-DRyJxYuK.js"></script>
...
config.js
located at same path as index.html
we set up BASENAME
window.__config__ = {
BASENAME: '/record-manager',
...
}
App.jsx
we specify relative path of pages within BrowserRouter using BASENAME
:
<Router history={history} basename={BASENAME}>
BASENAME=/my-company/my-record-manager
).The problem:
base="/"
since, in some cases, we serve nginx from subpath of BASENAME (e.g. /my-company
) and thus are not able to locate index.html at the address "http://localhost/index.html". This is also the case when we serve multiple applications (multiple index.html / config.js
files would exist and we cannot serve them all at "/") .base=""
(same as base="./"
), because it works on the same level (subpath) of URL as index.html, but if we have a more complex path, it will not work (e.g. http://localhost:1235/record-manager/records/61920918389810463
would resolve to http://localhost:1235/record-manager/records/config.js
and not http://localhost:1235/record-manager/config.js
where index.html
is also located)Alternative possible solutions to fix the dockerization:
*.js
files from the server:
/record-manager/records/config.js
would be resolved to /record-manager/config.js
/record-manager/assets/*
npm run prod
in there with the correct ${base} parameter specified from the docker entrypoint scriptvite
-specific docker imagesCurrently this is not that important now, so putting back to state TODO.
This answer helped me a lot, maybe it will help you as well: https://stackoverflow.com/a/67195723/4929038
There is no way to go to a specific screen of the application using URL, as all specific addresses always redirect to the main dashboard.
Let's show it on the screen /institutions:
As in fta-fmea-ui, we use browser-router in the front-end, but in the fta-fmea-ui it works well. Note that this issue is quite old, so it was not caused by migration to Vite.
A/C: