What are the disadvantages of using relative paths for all spa single-page application resources?

vue-cli or create-react-app default that the resource reference path after build is an absolute path, which needs to be run in the root directory of the server. What are the disadvantages of this method by changing the reference path to a relative path, such as changing assetsPublicPath to". /"in vue and adding homepage:"."to package.json in react, which can be accessed locally directly after build, and there is no problem to put it in the server? -sharp-sharp-sharp problem description

Oct.14,2021

if a single page needs seo, it must be an absolute path.


can prevent others from stealing items


feels that the main use is virtual paths, such as

<img src="/img/logo.png">

notice that there is a "/" character before "img". This "/" represents the root of the virtual directory. When a web service accesses a resource, it can access the resource through a virtual directory set by the server, rather than through the real physical path "C:workspaceadmin-systemimglogo.png".


there is no absolute path, which is divided into two parts.

  1. frontend
    / 1.jpg or . / 1.jpg addresses are processed into targets url in the browser based on the current url . Such as https://img.codeshelper.com/upload/img/2021/10/14/y0hvcdua4jx154.jpg or https://img.codeshelper.com/upload/img/2021/10/14/rzvrjcgb4ux155.jpg
  2. backend

http service parses path according to url , and then goes to the local directory of the server according to the mapping relationship of http service configuration.

so there is no absolute path from beginning to end, just different rules for assembling url using browsers.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2b178-2ba70.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2b178-2ba70.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?