Allow serving the GUI from a subdirectory#520
Conversation
|
When this works, "Simple build-time configuring Zonemaster-GUI using 'config.ts'" in zonemaster/zonemaster#1442 must be updated correct instructions. |
|
@tbleckert and @rhedman, do you see any issues with the solution in this PR? |
b059087 to
b8cee3e
Compare
Not |
|
Are the changes in |
I don't see any issues, looks good! |
Sort of both. While fixing the issue addressed in this PR, I was trying to use the |
b8cee3e to
374555a
Compare
Is it possible to change so that |
Maybe. But the release time is approaching quickly and I do not want to introduce any more changes than necessary. I am not familiar enough with JavaScript or TypeScript to implement such a change. But your suggestion on the Apache configuration file looks good. I’ll implement it. |
|
I’m not sure these suggestions are going to work. I tried going the There is a big difference between If and IfDefine blocks: If blocks are evaluated at each request, while IfDefine is evaluated when the configuration is being parsed. As far as I know, I can’t use anything else but IfDefine here. |
|
Tried it, and Apache rejects the configuration file: |
|
I got a new suggestion from ChatGTP: I will check. |
|
I will suggest a new conf file, if successful. |
374555a to
55190e3
Compare
tgreenx
left a comment
There was a problem hiding this comment.
LGTM, but I haven't tested it yet.
MichaelTimbert
left a comment
There was a problem hiding this comment.
Tested on Rocky 8, work fine.
matsduf
left a comment
There was a problem hiding this comment.
It works when testing with a subdirectory, but it does not work when just using as-is. @MichaelTimbert, did you test without subdirectory?
Secondly, I hope to have an configuration where you should change fewer things.
|
I propose the following to replace |
|
I have tested my proposal both with and without subdirectory and for me it has worked correctly. Else things works well and I have updated the documentation accordingly (see zonemaster/zonemaster@d9fb884). |
In order to support use cases where the GUI is served from a non-root base URL (i.e. https://zonemaster.example/some/subdirectory instead of https://zonemaster.example), some modifications were necessary to some Astro and Svelte files in the project. I initially tried to keep my modifications to the Apache configuration files without touching anything else, but I quickly realized that it couldn’t be done by editing Apache configuration files alone. That is because the build process assumes that the site is served from a base directory of / and all HTML files have baked-in absolute URLs. Fortunately, astro.config.mjs allows setting a base path that can be easily referred to from Astro and Svelte files. Setting it fixed *almost* everything: CSS and JS assets load from the right place, but favicons did not and some link target URLs needed manual adjustment in order to include the base directory. I am not familiar with these technologies and there might be a better approach to some of the edits I’ve made to Astro and Svelte files. So instead of having to edit the Apache configuration file, one needs to edit that file and config.ts in order to set the base URL to a non-default value. This seems to me like an acceptable compromise.
55190e3 to
1a1f739
Compare
Okay, thanks for the proposal! I’ve committed it in the latest iteration. |
f415d0a
into
zonemaster:releases/ssg-standalone-components
Purpose
This PR makes some modifications so that the GUI can be served from a non-root path, such as https://zonemaster.example/some/subdirectory.
Context
Release testing for 2025.2.
Changes
config.tsand use it inastro.config.mjs.How to test this PR
Assuming there is already a GUI installed on your machine:
config.tsand override thebaseUrl(e.g.baseUrl: "/some/subdirectory") and theapiBaseUrl(e.g.apiBaseUrl: "/some/subdirectory/api").npm run releaseto build the GUI./var/www/html/zonemaster-web-guiwith the contents of the newly-generated ZIP file./etc/apache2/sites-enabled/zonemaster.conf) with the newly-generated example file (/var/www/html/zonemaster-web-gui/zonemaster.conf-example).Define BASE_URLand setBASE_URLto"/some/subdirectory".