http.js 515 B

123456789101112131415161718
  1. "use strict";
  2. const common_vendor = require("../common/vendor.js");
  3. var define_import_meta_env_default = {};
  4. const baseURL = define_import_meta_env_default.VITE_API_URL;
  5. const httpInterceptor = {
  6. // 拦截前触发
  7. invoke(options) {
  8. if (!options.url.startsWith("http")) {
  9. options.url = baseURL + options.url;
  10. }
  11. options.timeout = 3e4;
  12. options.header = {
  13. ...options.header,
  14. "source-client": "miniapp"
  15. };
  16. }
  17. };
  18. common_vendor.index.addInterceptor("request", httpInterceptor);