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

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 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.

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.

Related

Tricky redirect/rewrite

I searched for this one, but found nothing ...
My old site is: cs.abc.edu/~cs4096
My files were at: cs4096#cs.abc.edu/public_html
My personal site: myname.com
My Github Pages site: myname.github.io
When a user requests cs.abc.edu/~cs4096 they are served cs.abc.edu/~cs4096/index.html and so on.
Via the ISP hosting myname.com, I setup a CNAME pointing teaching.myname.com to myname.github.io .
I want references to the old site, including pages below the top index.html, to be sent to teaching.myname.com where through the magic of DNS CNAME the URL goes to the myname.github.io site. In other words, users still go to the cs.abc.edu/~cs4096 but they are served from github.io.
The teaching.myname.com -> myname.github.io bit is working fine. It’s the initial redirect/rewrite that is failing. The problem is that the ~cs4096 is included in the URL when it is passed to myname.com .
That is, this
http://cs.abc.edu/~cs4096
ends up as
http://teaching.myname.com/index.html~cs4096
instead of
http://teaching.myname.com/index.html
and this
http://cs.abc.edu/~cs4096/Schedule
ends up as
http://teaching.myname.com/index.html~cs4096/Schedule
instead of
http://teaching.myname.com/Schedule
And, if you wonder WHY I’m doing two “redirects” here, it is because want the automatic rebuild of github pages that I can’t get at abc.edu or myname.com .
Thank you all
Never mind ... I abandoned this idea and used an HTML Redirect. It will mess up “Back” in the Browser, but it works.

How do I use #{request.contextPath} when the context root is, well, root: "/"?

We are currently moving an EE6 / JSF application from a deployment path someserver.com/app to its own subdomain app.someserver.com.
Most things are working smoothly, but we have had unexpected troubles with how the web layer handles the now basically nonexistent context-root.
One thing we found and fixed early was that a cookie we set had its path shortened from "/app" to "", and thus was only readable per folder on the server, not for the entire application.
We have now found a similar problem with hyperlinks that we generate in JSF:
Go to home page
This was previously rendered as href="/app" and worked fine, but now with href="" the link is understandably no longer active. I want it to say href=""/".
Is there an elegant solution for that?
Keep in mind that we also have links of the form
Go to projects page
, so simply replacing the empty context path with "/" is not good enough.
Am I missing something obvious? I saw an explanation here (which matches what we experience), but no elaboration on possible solutions.
Turns out I wasn't thinking clearly. I was so focused on fixing the string that #{request.contextPath} produces, that I missed that I basically used it wrong the entire time.
The simplest solution is to just use
...
(with a trailing slash) to get to the root of the application, and never use href="#{request.contextPath}" without a slash at all.
This solves both cases. If the application is deployed to "some_folder", the link becomes "some_folder/". And if the application is deployed to the server root, then the link becomes "/".
Hope this helps someone who stumbled into the same trap.

Best practice - document root, git and dist/src folders

First of all, I'm sorry if this question is pretty much a best practice question, rather than me asking for some help from you guys.
Basically, I'm new to webmaster stuff (as I am a web developer, but I've never had to manage domains / hosting before.
The way I usually work is with having the source code and the distribution code into two different folders, as some of my source gets compiled into the dist folder (some, not everything!)
I also use git as a source code tracker and then on the server I use git command line to push, pull switch branch and so on.
So, the problem I've got is that in git I have both folders (both dist and src) that get pushed.
Let me write down an example:
let's say I have a domain called www.mydomain.com
When I clone the repository into www.mydomain.com, the server root, if I navigate to the domain, above looks like this:
index of:
src/
dist/
and os to have the proper website, the URL needs to be www.mydomain.com/dist.
If I append dist at the end, it works, but I don't like it. I so tried to change the server document root in my Cpanel account from /domains/mydomain.com to /domains/mydomain.com/dist hoping that this would tell the website to look directly into the dist folder as a root document folder and not the level up.
That, unfortunately, didn't work.
I also tried with a redirect, but again, dist gets appended at the end of the URL.
I also started to look into git post-commit hooks, but I'm not sure that's the right path to follow.
Basically, after this very long question, all I'd like to know is a
best practice to handle two folders pushed on the server with git, but
having the URL point to one without having the URL to display the
subfolder name. Is that possible? do I need to setup the .htaccess
file to do that or is something that needs to be done when setting up
the domain name?
Thanks for any suggestion

Rails Redirect Route Bad Host Component

So I'm trying to make a redirect in my routes.rb. I'm getting an error when I leave off my domain.
match "/partners/" => redirect("/partners.html")
Navigating to /partners/ gives this error page:
URI::InvalidComponentError
bad component(expected host component): frontend_rails.dev
However, it does work if I put our full domain in the redirect.
match "/partners/" => redirect("http://example.com/partners.html")
But for my dev server I don't like links to go to our production server. According to the rails doc, this should be added automatically:
In all of these cases, if you don’t provide the leading host (http://www.example.com), Rails will take those details from the current request.
Any ideas why it's not liking my relative redirects? Thanks!
Almost a year later and I finally realized what the problem was. It actually WAS a bad URI. The repo in GitHub was called frontend_rails. I used the Pow server, which gives you a host based on your folder name (which, when you check out a project defaults to the name of the GitHub repo), so http://frontend_rails.dev.
However, underscores technically aren't allowed in a URI. This was tripping up the URI gem. I symlinked my project frontend_rails to frontend-rails and now it works. Voilà !

Symfony 1.4 Backend app for admin fail on Prod environment

I have a perfectly working admin backend on my dev environment but it fails miserably on the prod environment. Specifically a bunch of problems arise :
It is unable to read the symfony/web/sf/ directory hence not loading the required images though it states that a project has been successfully created. This however is not the case with the frontend leading me to believe that the problem is more sinister than what meets the eye.
Though it loads the admin pages, the css is not loaded, even though admin.css is present in the web/css directory.
I did an inspect element and the problem seems to be this, instead of routing to
/web/css or /sfDoctrinePlugin or /web/js
it prefixes the name of the app [controlcenter in my case] to everything, essentially rendering the HTML as:
href = "/controlcenter/web/css" or href = "/controlcenter/js" or href = "/controlcenter/js" . And this does not happen at all on my dev environment and things render the way they do.
Fixits anyone?
This was completely ridiculous of me to post this. I was simply trying to go to controlcenter/module which basically translates to backend/module for most people.
The index file in this case is controlcenter.php, and upon accessing that, I get the website to render the way it ought to. Sorry for the confusion people. Hopefully someone drops in by and sees the answer for themselves.
I should set up defaults in my routing.yml so that it automatically redirects without me having to type controlcenter.php
Thanks

Resources