[英]Browser not able to parse manifest.json in Node.js application after deploying it to Cloud foundry
I have created a Node.js application with angularJS. 我已经用angularJS创建了一个Node.js应用程序。 I need to add 'Add to Homescreen' functionality to the application. 我需要向应用程序添加“添加到主屏幕”功能。 So I have added the manifest.json as below. 所以我添加了manifest.json如下。
{ "name": "TEST-APP", "short_name": "TEST-APP", "version": "0.0.0.1", "background_color": "#313131", "theme_color": "#313131", "manifest_version": 2, "icons": [ { "src": "images/Test-App.png", "sizes": "192x192", "type": "image/png" }, { "src": "images/Test-App.png", "sizes": "512x512", "type": "image/png" } ], "start_url": "http://localhost:6001/", "display": "standalone" }
While testing the application in localhost, it able to parse the manifest. 在本地主机中测试应用程序时,它能够解析清单。 But after deploying it to Cloud Foundry, i am getting the below error. 但是将其部署到Cloud Foundry之后,出现以下错误。 Please help me with this. 请帮我解决一下这个。
i have tried Changing the manifest.json encoding to UTF-8. 我曾尝试将manifest.json编码更改为UTF-8。
There really shouldn't be that much of a difference from running locally vs running on CF. 与在CF上本地运行和在本地运行之间确实没有太大的区别。 Here's some things you can check though... 您可以通过以下方法检查...
Look at the output of staging (ie the nodejs buildpack). 查看暂存的输出(即,nodejs buildpack)。 Make sure it's installing the same version of Nodejs & packages that you're using locally. 确保它安装了与本地使用的相同版本的Node.js和软件包。 The buildpack tends to default to the newest/latest versions of things. buildpack倾向于默认为事物的最新/最新版本。 If you're using an older version locally, you may see differences. 如果您在本地使用的是旧版本,则可能会看到差异。
Look at the actual manifest.json
file that is being served up from the app when running on CF. 查看在CF上运行时从应用程序提供的实际manifest.json
文件。 It is possible that it's not serving up what you expect and thus JSON cannot be parsed. 可能无法满足您的期望,因此无法解析JSON。 For example, accessing the JSON could return a 404 or a server error. 例如,访问JSON可能返回404或服务器错误。 These would not be valid JSON and thus would fail. 这些不是有效的JSON,因此将失败。 If you switch to the Network tab, you can see if there were issues & you can see the exact response data returned. 如果切换到“网络”选项卡,则可以查看是否存在问题,还可以查看返回的确切响应数据。
You can install the cf local
plugin. 您可以安装cf local
插件。 This allows you to run your app using the same buildpack that runs it on CF, but in a local Docker container. 这使您可以使用在CF上运行应用程序的同一buildpack来运行您的应用程序,但是在本地Docker容器中。 It allows you to validate the "runs locally fine" theory while using the exact same versions of software that will run your app on CF. 它使您可以在使用完全相同版本的将在CF上运行您的应用程序的软件时,验证“本地运行良好”的理论。
https://github.com/cloudfoundry-incubator/cflocal https://github.com/cloudfoundry-incubator/cflocal
Hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.