'Displaying website image testing vs. production

I am currently working on updating a .NET Core website which currently has image tags displaying from a URL like:

<img src="https://page.website.com/images/image.png">

However during testing, I have changed image.png on my development machine. So if I point to the live URL above, it gives me the old image. As a result, I have been testing with:

<img src="http://localhost/UserInterface/Images/image.png">

which properly displays the new image. My question is, when I commit my code, would https://page.website.com/images/image.png properly map to the updated image (included in git add) when the webpage is tested in QA or run in production? Is this a reasonable assumption to make, or otherwise, how could I test it with the production URL?

These image tags are included in an .html.cshtml file used for the UI of an email.

I am happy to provide more information if necessary.



Solution 1:[1]

There could be several approaches to test the thing like that:

  1. Use relative paths for your inner resources, hence whatever environment you would use, the resource would always be relevant
  2. Use templating so that when you build your app, the builder would put relevant source so that you would have different for different environments
  3. Use proxies that would forward some URLs to some other URLs so tyhat you would be able to map your "old" source to your "test" source.
  4. (not recommended) Redefine some server names in your local machine (for example using hosts file). So that the client would call not the real production server. This might require some reconfiguration of the server that hosts "new" resources since your test server might not accept the name of your prod server.

Solution 2:[2]

Yes server will use the correct image if you committed new image in repository to deploying it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexey R.
Solution 2 Narges Mousavi