npm packages are not found - SyntaxError: Unexpected token '<'

npm packages are not found - SyntaxError: Unexpected token '<'

我是 运行 Kubernetes env (AKS) 中的反应容器 istio gateway

在本地环境中,使用 docker build && docker run

一切正常

在 Kubernetes 中,对于每个 npm 包,我得到的响应是 status code: 200, response content-type: text/html,响应内容是 index.html,这就是为什么我假设找不到包?

Istio 网关

spec:
  selector:
  istio: ingressgateway
  servers:
    - hosts:
      - dev.myDomain.com
      port:
        name: https
        number: 443
        protocol: HTTPS
      tls:
        credentialName: someCreds
        mode: SIMPLE

Istio 对比

   - match:
    - uri:
        prefix: /base-app
     route:
      - destination:
          host: svc-app
          port:
            number: 8000

请求示例 + headers

Request URL: https://dev.myDomain.com/base-app/npm.babel.4fca5....chunk.js
Request Method: GET
Status Code: 200 
Remote Address: xxx.xxx.xxx:443
Referrer Policy: no-referrer-when-downgrade

回复Headers

accept-ranges: bytes
content-length: 11920 ---> length of index.html
content-type: text/html --> bad needs to be text/javascript
date: Tue, 11 Aug 2020 21:30:07 GMT
etag: "5f32aff9-2e90"
last-modified: Tue, 11 Aug 2020 14:49:29 GMT
server: istio-envoy
status: 200
x-envoy-upstream-service-time: 4

默认情况下,Istio 将从 https://dev.myDomain.com/base-app/npm.babel.4fca5....chunk.js 代理到 http://pod_ip:8000/base-app/npm.babel.4fca5....chunk.js,据我所知,您的图像直接从 /dist 提供文件,因此 Istio 实际上应该代理到http://pod_ip:8000/npm.babel.4fca5....chunk.js;注意缺失的 /base-app/。为此,请尝试将 Istio 虚拟服务更新为:

- match:
  - uri:
      prefix: /base-app
  rewrite:
    uri: /
  route:
  - destination:
      host: svc-app
      port:
        number: 8000