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
187 views
in Technique[技术] by (71.8m points)

How do I run a local server for an App Engine / Node.js app with an app.yaml file?

I'm using Google App Engine and Node.js. I'm able to follow all the instructions for a basic app without issue.

However, I'd like my app.yaml file to contain handlers sections to serve static files (as documented), e.g.

- url: /app.css
  static_files: static/app.css
  upload: static/app.css

The documentation for Node.js on App Engine says to simply run npm start to run my server, but that just runs the Node server, not the App Engine server that's configured by app.yaml. That means my local server serves a page, but the request for CSS fails!

I can't figure out how to run something (without deploying to App Engine) that will serve both my Node app and the static files. How can I quickly start a server that's similar to what will run in production?


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

1 Reply

0 votes
by (71.8m points)

You could go either serving locally or using express.static on both environments and both options would be working solutions for your issue.

That being said, I personally don't like the idea of having different solutions implemented for Prod and Dev environments (on a general note) as it may cause different behaviours between your environments and make it difficult to notice errors before they reach the Prod environment.

So I would use the express.static approach on both environments.


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

...