vite配置

  1. server: {
  2. proxy:{
  3. '/api/': {
  4. target: 'https://onramper.tech/',
  5. changeOrigin: true,
  6. rewrite: path => path.replace(/^\/api/, '')
  7. }
  8. }
  9. }

api配置

  1. /*
  2. * @Date: 2022-04-02 10:06:51
  3. * @LastEditTime: 2022-04-02 15:19:06
  4. */
  5. import fly from 'flyio'
  6. fly.config.baseURL = "/api";
  7. // 处理代理
  8. /**
  9. * @description: 验证邮箱订单
  10. * @param {string} apiKey, params
  11. * @return {*}
  12. */
  13. export function vertifyOrder(apiKey, params) {
  14. return fly.post(`/wayPoint/Moonpay/email/${apiKey}`, params, {
  15. headers: {
  16. authority: "onramper.tech",
  17. authorization:
  18. "Basic pk_test_x5M_5fdXzn1fxK04seu0JgFjGsu7CH8lOvS9xZWzuSM0",
  19. },
  20. });
  21. }
  22. export function getFee() {
  23. return fly.get("/partner/fees", null, {
  24. headers: {
  25. authority: "onramper.tech",
  26. authorization:
  27. "Basic pk_test_x5M_5fdXzn1fxK04seu0JgFjGsu7CH8lOvS9xZWzuSM0",
  28. },
  29. });
  30. }
  31. export function vertifyEmail(apiKey, email) {
  32. fly.config.baseURL = "https://api.moonpay.io/";
  33. return fly.post(`/v3/customers/email_login/${apiKey}`, { email });
  34. }
  35. export function emailLogin(apiKey, {email,securityCode}) {
  36. fly.config.baseURL = "https://api.moonpay.io/";
  37. return fly.post(`/v3/customers/email_login?apiKey=` + apiKey, { email,securityCode });
  38. }

控制台请求显示

实际请求url: https://onramper.tech/partner/fees

image.png