Search code examples
javascripthtmlvue.jshref

Axios get html and a href change to localhost instead of original path


I strungle with this, in resume I'm using axios to get a directory content of a remote server in other network. The path of the directory in that server is : enter image description here

my front response.data is like this: enter image description here

I'm using a div and

document.getElementById('content').innerHTML = response.data; 

inside the .get function to load all the html included de 'a' tags but href changed.

Now is like this: enter image description here

so the problem is that it changed the href from 192.168.110.83:8080/signed/ to localhost:8080/

how can i maintain the original href?? or is it imposible to make it?


Solution

  • you can manage original href like:

    const htmlContent = response.data.replace(/http:\/\/192\.168\.110\.83:8080\/signed\//g, '/signed/');
    document.getElementById('content').innerHTML = htmlContent;