Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
501 views
in Technique[技术] by (71.8m points)

node.js - How can I use bucket storage to serve static files on google flex/app engine environment?

I have a nodejs backend and a reactjs frontend. I am using the gcloud flex environment (app engine) and want to serve all the frontend files using a CDN. I would not want the requests to touch my nodejs server. I am unable to configure my projects app.yaml to do the same.

I suspect that my requests are not being served from a CDN because if I comment the below line in my nodejs code, I can no longer access index.html .

app.use('/', express.static(path.resolve('./frontend/dist')));

Below is the YAML file.

handlers:
- url: /(.*.html)
  mime_type: text/html 
  static_files: frontend/dist/1 
  upload: frontend/dist/(.*.html)

- url: /styles/(.*.css) 
  mime_type: text/css 
  static_files: frontend/dist/styles/1 
  upload: frontend/dist/styles/(.*.css)

- url: /scripts/(.*.js) 
  mime_type: text/javascript 
  static_files: frontend/dist/scripts/1 
  upload: frontend/dist/scripts/(.*.js)

- url: /images/(.*.(bmp|gif|ico|jpeg|jpg|png)) 
  static_files: frontend/dist/images/1 
  upload: frontend/dist/images/(.*.(bmp|gif|ico|jpeg|jpg|png))

- url: / 
  static_files: frontend/dist/index.html 
  upload: frontend/dist/index.html

-  url: /.* 
  script: IGNORED
  secure: always

Is there a way to configure app engine such that the static file requests don't react my nodejs backend servers?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...