Relative path issue on deployment server in AngualarJS app

Coding Duchess

In my Visual Studio project I have the following hierarchy:

index.html
/Images
/Scripts
/App
    /login/login.html
    /page1/page1.html

login.html and page1.html are partial pages that are rendered inside a ui-view div on index.html page.

On both login.html and page1.html I have some images to which the path is specified in the following way:

<img id="img1" src="../../Images/img_1.jpg">

It works fine, but when I move the application on the server where I am hosting it, the image is not found even though directory structure is the same.

What i have to do on the server is to change all paths to "Images/img_1.jpg", then it works.

So if I do not change anything, the app is looking at:

http://server3/Images/img_1.jpg.

And the image is really in

http://server3/myproject/Images/img_1.jpg

On my dev machine the image path shows up at

http://localhost:61777/Images/img_1.jpg

so clearly on the server it translates to

http://server3/Images/img_1.jpg

I have tried fixing an issue of image not being found by changing the path in ng-error (onerror):

<img id="img1" src="../../Images/img1.jpg" ng-error="SetPath(this, 'Images/img1.jpg')">

my javascript

 function SetPath(el, path) {
    el.src = path;
 }

So I would not have to do that manually, but it does not work, the javascript does not get called.

Can anyone suggest a fix that works?

One thing is I cannot reconfigure app in IIS on my machine as I do not have access to it

Aynolor

The app translates image path from index.html base path so :

On server : http://server3/myproject/../../Images/img_1.jpg is translated to http://server3/Images/img_1.jpg

On your dev machine : http://localhost:61777/../../Images/img_1.jpg is translated to http://localhost:61777/Images/img_1.jpg. It works because your app isn't in a subfolder.

If you put <img id="img1" src="./Images/img1.jpg">, it should work in both environments.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Server behind nginx reverse proxy ignores relative path in URL

From Dev

PHP App Engine deployment issue

From Dev

style tag relative path issue with ejs

From Dev

Create a file relative path for secure server certificate

From Dev

Issue With Relative Imports In Python

From Dev

Xcode Server Bot Issue: warning. Build Service Error. Issue: archive at path 'some/path' is malformed

From Dev

Relative path issue in node js

From Dev

Saving Path Name with Back Slash On The Server Issue

From Dev

Relative virtual path is not allowed when using server.MapPath()

From Dev

Relative path Issue - TypeScript compiler behaving differently on Windows vs Linux

From Dev

Relative path in html with php server

From Dev

How to create file on server with file path relative to application?

From Dev

Typescript Compiler of the App Deployed to Google App Engine does NOT resolve non-relative path

From Dev

JAR file not finding embedded resource -- issue with relative path?

From Dev

django templatetags path on deployment server not found

From Dev

Android relative layout issue

From Dev

App crashing on network issue/server down

From Dev

Reordering the deployment artifacts in Glassfish App Server in IntelliJ IDEA

From Dev

inject bower dependencies with gulp - relative path issue

From Dev

Application starting issue websphere application server 8.5 after deployment Jenkins

From Dev

Relative path issue in node js

From Dev

Get relative Path of WebContent in Spring webmvc app

From Dev

Meteor: relative/absolute path issue

From Dev

Relative path in html with php server

From Dev

Relative path and mod_rewrite issue

From Dev

Windows 10 Shortcut Relative Path to Batch File (for Portable App)

From Dev

Issue with relative file path resolving in Saxon implementation of EXPath file library

From Dev

Angular app deployment issue on Heroku

From Dev

How to refer to a relative path of a YAML file in a Google App Engine project?

Related Related

  1. 1

    Server behind nginx reverse proxy ignores relative path in URL

  2. 2

    PHP App Engine deployment issue

  3. 3

    style tag relative path issue with ejs

  4. 4

    Create a file relative path for secure server certificate

  5. 5

    Issue With Relative Imports In Python

  6. 6

    Xcode Server Bot Issue: warning. Build Service Error. Issue: archive at path 'some/path' is malformed

  7. 7

    Relative path issue in node js

  8. 8

    Saving Path Name with Back Slash On The Server Issue

  9. 9

    Relative virtual path is not allowed when using server.MapPath()

  10. 10

    Relative path Issue - TypeScript compiler behaving differently on Windows vs Linux

  11. 11

    Relative path in html with php server

  12. 12

    How to create file on server with file path relative to application?

  13. 13

    Typescript Compiler of the App Deployed to Google App Engine does NOT resolve non-relative path

  14. 14

    JAR file not finding embedded resource -- issue with relative path?

  15. 15

    django templatetags path on deployment server not found

  16. 16

    Android relative layout issue

  17. 17

    App crashing on network issue/server down

  18. 18

    Reordering the deployment artifacts in Glassfish App Server in IntelliJ IDEA

  19. 19

    inject bower dependencies with gulp - relative path issue

  20. 20

    Application starting issue websphere application server 8.5 after deployment Jenkins

  21. 21

    Relative path issue in node js

  22. 22

    Get relative Path of WebContent in Spring webmvc app

  23. 23

    Meteor: relative/absolute path issue

  24. 24

    Relative path in html with php server

  25. 25

    Relative path and mod_rewrite issue

  26. 26

    Windows 10 Shortcut Relative Path to Batch File (for Portable App)

  27. 27

    Issue with relative file path resolving in Saxon implementation of EXPath file library

  28. 28

    Angular app deployment issue on Heroku

  29. 29

    How to refer to a relative path of a YAML file in a Google App Engine project?

HotTag

Archive