Resolve root relative URLs when webapp is deployed to non-empty path - http

A webapp uses URLs of the form /images/image1.png, i.e. starting with a /.
The webapp should be deployed to a URL of the form http://myhost.example.org/webapp, i.e. the path part of the URL is not empty.
In a default setup the browser would try to get the image from http://myhost.example.org/images/image1.png and fail. What options do exist to make the browser resolve to http://myhost.example.org/webapp/images/image1.png without changing anything in the webapp?
I am using nodejs/keystonejs for the webapp and nginx as a reverse proxy.

Related

AWS amplify not rendering image using the dynamic online url while local build render image correctly

Locally I got:
The deployed version I got:
I'm not sure why the service URL is added before the image URL.
And the wired thing is the dynamic url path does not load correctly while the static path works well.
I guess it might have to do with the path redirection so below is my setting:

Vue static resource access with relative path

I am implementing an app using vue (my first one =) ). vite is my development environment tool. The problem is;
resources are mapped with relative paths; "./
If I load the app via /, here no problem.
If I try to load the app via /app then the resources asked from the root path again and expectedly the proxy does not forward the requests to server and expectedly a resource loading failure.
I would like to make my app load resource relatively. since these are two different parts in the network, I do not want to map all assets depending on my proxy's routing config.

Having different image url paths depending on stage

to preface: Im running a vue / spring webapp. My application on localhost runs under
"localhost:8080/application/"
while on DEV and TEST it runs under http://application-dev/ and http://application-test/ - so the /application prefix is missing.
In my sass I have the following image url paths: url("/application/image.png")
And on the DEV and TEST webservers I made redirects from /application to / to have it find the images.
Now I want to remove the "/application" part from my images and still get it to work on localhost.
Is there any way I can have a variable in my sass like "{contextpath}/image.png" and let the Spring webapp fill in the contextpath depending on where its deployed? So if I deploy at localhost the path would be ="/application" and if I deploy on test it would need to be equal to an empty string.
Is this even possible? tyvm

BaseURL in symfony 2

I have an application in Symfony 2. It is deployed on IIS server.
The problem is, I need to get it work on multiple URLs:
www.somedomain.com/myapp/app.php - for production
www.somedomain.com/myappdev/app.php - for testing
myapp.localhost/app.php - for development
How can I do that? I need to correctly generate URL for resources(js, css files). Also after deployment, generated URL are missing the /myapp/ (/myappdev/) segment.
You can prefix your routes with /myappdev by adding it to your app/config/routing.yml file under the prefix key.
If you use relative URLs for the resources then you won't have a problem with the domain it's on and it will work anywhere you put it.

What IIS 6.0 setting determines how a path is resolved?

I have a website that is deployed between 3 different environments - Dev, Stage, and Prod. For Stage and Prod, the site can resolve local paths to images with just the base url to the file, such as /SiteImages/banner.png. However, on the Dev server I have to hard code the full URL of the image path for the image to be resolved, such as http://server/folder/SiteImages/banner.png. Is there a setting I can flip to make the Dev server behave in the same manner as the other 2? I am using IIS 6.0 on a Win 2003 server.
There are usually three kinds of URIs that you can code in a website as far as I know.
Absolute: http://yoursite.com/somehing.jpg
This url includes the http:// and is
the full path to a resouce.
Root Relative:
/something/something.jpg
(In ASP.net
server-side only, you would use
'~/something/something.jpg')
This path is relative to the root of
your site.
File relative:
../something/something.jpg
This path
starts at the location of the file
that includes the URI. In this case,
it just back one directory (..) and
then goes back into the something
directory to look for something.jpg
What does the URL to the dev home page look like? Is it something like http://server/mydevsite/? If so, it sounds like you need to set up a virtual host.
Edit Just to clarify the above, say your prod and stage sites can be simply referenced as http://stagesite/ and http://prodsite/, if you use a path such as /images/myimage.jpg it assumes that the images folder are sitting in the root. In those two instances, no problem, images will display correctly. However, let's say your dev server is like the example I listed above. If your images are references as /images/myimage.jpg, instead of the server looking at http://server/mydevsite/images/myimage.jpg, it will instead look at http://server/images/myimage.jpg. If no images folder with the requested image exist in that server's root, you'll get an error.

Resources