WebApp 根据访问源获取访问API地址
2016-11-09 本文已影响0人
winzhyming
构建Web的API访问路径URL+Port
const origin = window.location.origin;
const protocol = window.location.protocol;
const hostname = window.location.hostname;
const port = 80;
const API_ROOT = protocol + "//" + hostname + ":" + port;
API_ROOT即为API的访问路径