Joseph Kaptur
Joseph Kaptur

Reputation: 143

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?

Upvotes: 2

Views: 475

Answers (1)

Rafael Lemos
Rafael Lemos

Reputation: 5819

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.

Upvotes: 1

Related Questions