Search code examples
gitlab-pages

Using Go Daddy domain with Gitlab pages is causing my resources to be referenced with the wrong path


I've configured the DNS for my Go Daddy domain to link to a gitlab pages URL the resources seem to be looked for at a path using the project name, which I am struggling to understand because the same thing works when using the gitlab URL:

Application using gitlab URL: Application using gitlab URL:

Application using domain name: Application using domain name:

in the second image if you remove the /mythosgames/ path the files are located there which is honestly what i would expect, and i would have thought that: https://glentopherlamb.gitlab.io/mythosgames/ = https://glentophergames.co.uk/

So I am kind of confused why that path works for the gitlab link, i would expect both to be wrong, can anyone point me in the right direction as to how to fix this. I fear i am in a little over my head.


Solution

  • Navigate to https://glentophergames.co.uk/, open the browser dev tools, switch to "network", refresh the page - and you'll see that there are some requests with error response codes.

    This is because you have specified the publicPath (with the value "mythosgames"), so now when the index is loaded, it's trying to load all the resources from the /mythosgames/ base path - which is incorrect when loading the page on your own domain, because in that case they should be loaded from the root (/) base path (no subfolder).

    You can "fix" this by setting the publicPath value to ./, so all assets are loaded relatively to the index.html file (or better said, relative to current path).

    Keep in mind that this can break apps with client-side routing using "legacy" (non hash) navigation.