简体   繁体   English

谷歌应用引擎部署我所有的反应文件甚至来源

[英]Google app-engine deploy all my react file even sources

I am using Google App Engine to host and serve my website, but I am encountering one issue when browsing on my website, I can retrieve all the source code I wrote in the dev tools:我正在使用 Google App Engine 来托管和服务我的网站,但是我在浏览我的网站时遇到了一个问题,我可以检索我在开发工具中编写的所有源代码: 检索到的文件

Here are the two commands I am using when building and deploying:这是我在构建和部署时使用的两个命令:

"build:prod": "env-cmd -f .env.production react-scripts build",
"deploy:client-production": "copy app_to_add_in_build.yaml build/app_to_add_in_build.yaml && cd build/ && move app_to_add_in_build.yaml app.yaml && gcloud app deploy --project myProjectId",

I am copying & renaming my app.yaml to the build folder then running the deploy from there.我正在将我的app.yaml复制并重命名到构建文件夹,然后从那里运行部署。

Here is the content of my app.yaml file:这是我的app.yaml文件的内容:

runtime: nodejs12

handlers:
  - url: '/service-worker.js'
    secure: always
    static_files: service-worker.js
    upload: service-worker.js
    mime_type: application/javascript

  - url: /(precache-manifest.*)$
    secure: always
    mime_type: application/javascript
    static_files: \1
    upload: ./(precache-manifest.*)$

  - url: /(.*\.js)$
    secure: always
    static_files: \1
    upload: .*\.js$
    mime_type: application/javascript

  - url: /(.*\.(css|map|png|jpg|svg|ico|json|txt|woff))$
    secure: always
    static_files: \1
    upload: .*\.(css|map|png|jpg|svg|ico|json|txt|woff)$

  - url: '/(.*)'
    secure: always
    static_files: index.html
    upload: index.html

Plus here is the content of the build folder另外这里是build文件夹的内容

构建文件夹的内容

As we can see, there are no source files inside.我们可以看到,里面没有源文件。

Once this is deployed, I browse the files in Google cloud debugger:部署完成后,我浏览 Google 云调试器中的文件:

谷歌云调试器文件

There are no source files inside.里面没有源文件。

I cleared my cache and cookies, reset my browser data, and tried with several browsers, I still have access to all Javascript/JSX sources.我清除了我的缓存和 cookies,重置了我的浏览器数据,并尝试了几个浏览器,我仍然可以访问所有 Javascript/JSX 源。 When serving the website, I see that it is using a React production build, but I am sure it's using the javascript files inside instead, as components are mounted twice ( https://medium.com/@andreasheissenberger/react-components-render-twice-any-way-to-fix-this-91cf23961625 ).在为该网站提供服务时,我看到它使用的是 React 生产版本,但我确信它使用的是内部的 javascript 文件,因为组件安装了两次( https://medium.com/@andreasheissenberger/react-components-render -两次任何方式来修复这个 91cf23961625 )。

I don't know where the issue comes from as nothing is cached anymore, neither on GCP, neither on my computer...我不知道问题出在哪里,因为不再缓存任何内容,既不在 GCP 上,也不在我的计算机上......

Do you have any clues if I did something wrong?如果我做错了什么,你有什么线索吗? Or any fixes?或者任何修复?

Thank you in advance先感谢您

After searching around and how the source code could be available, I try to serve it to myself and the code was still present.在四处搜索以及如何获得源代码之后,我尝试将其提供给自己,并且代码仍然存在。

After some other research I found that it's an intended feature or react scripts: create-react-app is showing all my code in production, how to hide it?经过一些其他研究后,我发现这是一个预期的功能或反应脚本: create-react-app is showing all my code in production,如何隐藏它?

Is there ever going to be a situation where you want these sources files to be deployed / available on the remote server?是否会出现您希望这些源文件在远程服务器上部署/可用的情况? You could just opt to not even deploy them, by adding them to your .gcloudignore .您甚至可以选择不部署它们,只需将它们添加到您的.gcloudignore In the example below, all files ending in jsx would not get uploaded在下面的示例中,不会上传所有以 jsx 结尾的文件

*jsx

https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM