Because the previous e-commerce BBC of Shangpai was not suitable, we rewrote a set of e-commerce ourselves and needed to migrate the original data to the new system. We encountered a problem during the migration. The product details (html text) The image address src was hard-coded before. Considering that the image should be placed on the cdn later, the src should also change with the current cdn. How to save the image src properly?
Then the relative path must be saved
cdnHost + src
domain + src
Even if the image is placed on the cloud, disaster recovery must be considered. If the cloud is down, normal access can still be achieved by changing the prefix of the configuration items.
@Lowky is right. Generally, pictures only save relative paths to facilitate migration. The configuration file only needs to specify the domain name, such as
HOST=//sf.gg
# // Compatible with http and https<img src={{HOST}}/img/xxxx.jpg>
Do not retain the domain name, only the path behind the domain name, so that you can migrate to other domain names or clouds and modify it directly in the code. It is more convenient
That’s not how it is