- Nodejs (check the
komga-webui/.nvmrcfile)
You can run a live development server with npm run serve. The dev server will override the URL to connect to localhost:8080, so you can also run gradle bootRun to have a backend running, serving the API requests. The frontend will be loaded from localhost:8081.
Make sure you start the backend with the dev profile, else the frontend requests will be denied because of CORS.
The generated bundle is server by Apache Tomcat when running Spring. By default the site is hosted at /, but if server.servlet-context-path is set, the base URL can be dynamic.
The base URL needs to be set correctly so the web app works:
- in the API client
- in the Vue Router, to properly handle the web history
- in the generated bundle, to load other files (js/css/images)
-
Webpack is configured with
__webpack_public_path__to change the path dynamically. -
To handle the dynamic path in
index.html, a Gradle taskwebuiCopyIndexmodifiesindex.htmlto duplicatehref,srcandcontentattributes as Thymeleaf variants.For example the following:
<script type="module" crossorigin src="/assets/index-xEUJQodq.js" ></script> <link rel="stylesheet" crossorigin href="/assets/index-CQqFNa2f.css" />
will be transformed to:
<script type="module" crossorigin src="/assets/index-xEUJQodq.js" th:src="@{/assets/index-xEUJQodq.js}" ></script> <link rel="stylesheet" crossorigin href="/assets/index-CQqFNa2f.css" th:href="@{/assets/index-CQqFNa2f.css}" />
In Thymeleaf,
@{}will prepend the path with the context path dynamically when servingindex.html. -
when the
index.htmlis served by theIndexController, abaseUrlattribute is injected, which contains the servlet context path (by default/, but could be/komgafor example) -
the
index.htmlcontains a Thymeleaf script block that will be processed when serving the page, effectively injecting thebaseUrlvalue intowindow.ressourceBaseUrl. -
window.ressourceBaseUrlis subsequently used in Typescript code to set the base URL