最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Can I host my Reactredux (client and api server) project on github pages? - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

4 Answers 4

Reset to default 3

I 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 .

发布评论

评论列表(0)

  1. 暂无评论