Ver Fonte

地听视频跨域问题处理

linqilong há 3 meses atrás
pai
commit
16bc82513b
2 ficheiros alterados com 14 adições e 1 exclusões
  1. 8 1
      src/components/Video/video.ts
  2. 6 0
      vite.config.ts

+ 8 - 1
src/components/Video/video.ts

@@ -101,7 +101,14 @@ export async function getVideoSrc(code: string) {
   }
   closeVideo();
   curIndexCode = code;
-  return await getVideoUrl(curIndexCode, token).then(res => res.data.https_fmp4).catch(() => null)
+  return await getVideoUrl(curIndexCode, token)
+    .then(res => {
+      let url = res.data.fmp4;
+      // 修改url(解决跨域问题)
+      url = url.replace('http://10.8.4.147:8800', '/videourl_api');
+      return url;
+    })
+    .catch(() => null)
 }
 
 export function closeVideo(videoNm = curIndexCode, authorization = token) {

+ 6 - 0
vite.config.ts

@@ -56,6 +56,12 @@ export default defineConfig({
         changeOrigin: true,
         rewrite: path => path.replace(/^\/video_api/, '')
       },
+      '/videourl_api': {
+        // 地听视频
+        target: 'http://10.8.4.147:8800/',
+        changeOrigin: true,
+        rewrite: path => path.replace(/^\/videourl_api/, '')
+      },
       '/tsq_api': {
         // 南水太师桥
         target: 'http://10.8.251.166:8001/',