0

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: Files retrieved

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.

Here is the content of my app.yaml file:

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

content of build folder

As we can see, there are no source files inside.

Once this is deployed, I browse the files in Google cloud debugger:

Google cloud debugger files

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. 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).

I don't know where the issue comes from as nothing is cached anymore, neither on GCP, neither on my computer...

Do you have any clues if I did something wrong? Or any fixes?

Thank you in advance

Elsha
  • 37
  • 8

2 Answers2

1

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?

Elsha
  • 37
  • 8
0

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. In the example below, all files ending in jsx would not get uploaded

*jsx

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

Alex
  • 5,141
  • 12
  • 26