I often use the npm module json-server
to generate a fake JSON api given a db.json
file. Is there any way to deploy that to Heroku? Essentially, I just run
json-server --watch db.json
And it runs a server that also servers static html if there are any in the public/
directory. Essentially, I think it is just running a Node server, except I tried pushing to Heroku, but it did not work. Is there a special procedure I should do in order to make Heroku run that json-server
module as my server?
Deploy json-server to HerokuShould only be used in development purpose but can act as a simpler database for smaller applications.
Under the hood, Heroku will look for a startup-script, this is by default npm start
so make sure you have that in your package.json
.
Late to the party, but in case someone needs, just check out this repo, change the db.json
to what you want, then follow step-by-step instructions to deploy to Heroku.
If you want to consume your fake APIs from an application published on Heroku, AWS Elastic Beanstalk etc., use My Json Server https://my-json-server.typicode.com/ . As far as I know, it is free for a small json.db file.
All you need to do is:
https://my-json-server.typicode.com/<your-github-username>/<your-github-repo>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With