{"id":18353860,"url":"https://github.com/angelostavrow/starter-cra-and-react","last_synced_at":"2025-04-10T00:55:50.805Z","repository":{"id":147059113,"uuid":"241903379","full_name":"AngeloStavrow/starter-cra-and-react","owner":"AngeloStavrow","description":"A starter for using create-react-app and Express together on Glitch","archived":false,"fork":false,"pushed_at":"2024-12-17T18:55:53.000Z","size":985,"stargazers_count":0,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T00:55:44.106Z","etag":null,"topics":["create-react-app","expressjs","glitch","http-proxy-middleware"],"latest_commit_sha":null,"homepage":"https://glitch.com/~starter-cra-and-express","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AngeloStavrow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-20T14:21:21.000Z","updated_at":"2024-11-19T17:44:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"4512ed1f-d8df-408f-8866-8d3032f5e9e3","html_url":"https://github.com/AngeloStavrow/starter-cra-and-react","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloStavrow%2Fstarter-cra-and-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloStavrow%2Fstarter-cra-and-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloStavrow%2Fstarter-cra-and-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AngeloStavrow%2Fstarter-cra-and-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AngeloStavrow","download_url":"https://codeload.github.com/AngeloStavrow/starter-cra-and-react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137993,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["create-react-app","expressjs","glitch","http-proxy-middleware"],"created_at":"2024-11-05T21:43:18.134Z","updated_at":"2025-04-10T00:55:50.784Z","avatar_url":"https://github.com/AngeloStavrow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Starter create-react-app and Express\n\nGlitch only serves content on one port. This is typically not an issue, unless you're trying to run both a webpack development server for front-end work and a back-end server in the same project, at the same time — you get one port for serving resources, but both the front-end and back-end servers each want their own port! This is a common scenario when you're building your front end with [create-react-app], and your back end with [Express].\n\nThis starter app will get you on your way with this scenario!\n\n## Forwarding requests via a proxy\n\nIn **package.json**...\n\n1. if you set your `start` script to `\"npm run production\"`, it will build the React app and Express will serve the static bundle over port 3000.\n\n2. if you set your `start` script to `\"npm run development\"`, it will concurrently start the webpack dev server/watcher and the Express server. The latter will be listening on port 3001, but you don't need to change anything in your code because: proxies!\n\nAs it stands, the server listens for requests to `/api`; to get this working in `development` mode, we're using [`http-proxy-middleware`] in **src/setupProxy.js** to forward any incoming request to `/api/whatever/endpoint/you/have` over to the `target`, i.e., the Express server.\n\n## Live-reloading and watch.json\n\nThere's a **watch.json** file that specifies a couple of conditions to keep Webpack and Glitch from interfering with each others' file watchers:\n\n1. We only want to run `install` scripts when changes are made to the **package.json** and **.env** files. Installation can take a while, so we don't want to trigger it with any other changes.\n2. We only want to `restart` the project when changes are made in the **/server** folder, or to the **watch.json** file. We're including **watch.json** in case we need to kick off a restart — a change to the `throttle` value will trigger this. We're also explicitly ignoring any files in the **/public** and **/src** directories from kicking off a restart — we only want the Webpack watcher to handle these files.\n3. We're setting a `throttle` of 100, which means that the Glitch watcher will wait 100 milliseconds before restarting anything. If that seems too quick, you can increase it.\n\n## Made with Glitch\n\nGlitch is a collaborative programming environment that lives in your browser and deploys code as you type.\n\nUse Glitch to build anything from a good ol’ static webpage to full-stack Node apps.\n\n\n[create-react-app]: https://create-react-app.dev\n[Express]: https://expressjs.com/\n[`http-proxy-middleware`]: https://github.com/chimurai/http-proxy-middleware","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelostavrow%2Fstarter-cra-and-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangelostavrow%2Fstarter-cra-and-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangelostavrow%2Fstarter-cra-and-react/lists"}