I know I can host my react/redux app on github pages by just serving the bundle.js and index.html, but can I also host an api server for the backend that is say username.github.io/api?
The server uses node.js/express and they are separate directories.
Also, can I make the server repository private and still host it on /api?
I looked through the documentation on github pages about creating "projects" but it doesn't make much since to me.
If anyone can shed some light on this, it would be must appreciated.
I know I can host my react/redux app on github pages by just serving the bundle.js and index.html, but can I also host an api server for the backend that is say username.github.io/api?
The server uses node.js/express and they are separate directories.
Also, can I make the server repository private and still host it on /api?
I looked through the documentation on github pages about creating "projects" but it doesn't make much since to me.
If anyone can shed some light on this, it would be must appreciated.
Share Improve this question asked Sep 6, 2016 at 23:39 natephnateph 798 bronze badges 1- 1 No. GitHub Pages is for static files, not servers. – Jed Fox Commented Sep 6, 2016 at 23:40
4 Answers
Reset to default 3I suggest you run your front-end code on github while having an externally hosted api on say, AWS or google cloud.
Amazon and google both provide free packages for small scale operations!
This way you can have your github page request data from AWS or google cloud!
No. GitHub Pages are static. They're generated using a variation of Jekyll, a templated flat site generator. As such, they're only flat HTML, CSS and Javascript.
You could host your frontend React application in them, but not server-side application code or a database.
You are not allowed to run any custom server code on Github pages, you can only host static files (HTML, images, front-end javascript etc).
You could do that if you are able to convert your code to static HTML + Resources (JS+CSS+IMAGES+FONTS..). To do that, it is remended to use webpack
Once you finish coding, you build your project using :
NODE_ENV=production node_modules/webpack/bin/webpack.js --config webpack.config.prod.js
This will generate static HTML + JS of your code .
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745147183a4613699.html
评论列表(0条)