如何解决找不到npm软件包-SyntaxError:意外令牌'<'
我正在Kubernetes
环境(AKS)中运行带有istio gateway的react容器
在本地环境中,使用docker build && docker run
在Kubernetes中,对于每个npm软件包,我得到的响应为status code: 200,response content-type: text/html
,响应内容为index.html
,这就是为什么我假设未找到软件包的原因?
- 在检查docker dist内容时,我可以断言该程序包已经存在(例如存在
/dist/npm.babel.4fca54....chunk.js
- docker镜像是使用以下基本上下文构建的:
docker build -t imagename --build-arg PUBLIC_URL=/base-app .
- index.html是有效的,并且包含有效的脚本声明。例如
<script type="text/javascript" src="/base-app/npm.babel.743f....chunk.js"></script>
Istio Gateway
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- dev.myDomain.com
port:
name: https
number: 443
protocol: HTTPS
tls:
credentialName: someCreds
mode: SIMPLE
Istio VS
- match:
- uri:
prefix: /base-app
route:
- destination:
host: svc-app
port:
number: 8000
请求+标头示例
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
响应标题
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实际上应代理到{{ 1}};请注意缺少的http://pod_ip:8000/npm.babel.4fca5....chunk.js
。为此,请尝试将Istio虚拟服务更新为:
/base-app/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。