{"id":25050581,"url":"https://github.com/arnobt78/Mock-Server-CORS-Proxy-Employee-Management--ExpressJS-Backend","last_synced_at":"2025-10-21T06:32:04.419Z","repository":{"id":272139037,"uuid":"915631614","full_name":"arnobt78/CORS-Proxy-Server-Employee-API","owner":"arnobt78","description":"This project is a simple CORS proxy server using the `cors-anywhere` package. It allows you to bypass the same-origin policy in web browsers by proxying your requests through this server.  Frontend UI Source Code:  https://github.com/arnobt78/Employee-Management-App-Angular18","archived":false,"fork":false,"pushed_at":"2025-01-12T21:59:45.000Z","size":1,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T22:32:18.478Z","etag":null,"topics":["angular18","backend-server-side","cors-anywhere","cors-proxy","cors-request","crud-api","crud-application","crud-operation","render-deployment","server-side-rendering"],"latest_commit_sha":null,"homepage":"https://cors-proxy-avym.onrender.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnobt78.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-01-12T11:48:41.000Z","updated_at":"2025-01-12T22:03:40.000Z","dependencies_parsed_at":"2025-01-12T22:32:24.862Z","dependency_job_id":null,"html_url":"https://github.com/arnobt78/CORS-Proxy-Server-Employee-API","commit_stats":null,"previous_names":["arnobt78/cors-proxy","arnobt78/cors-proxy-server-employee-api"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FCORS-Proxy-Server-Employee-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FCORS-Proxy-Server-Employee-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FCORS-Proxy-Server-Employee-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnobt78%2FCORS-Proxy-Server-Employee-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnobt78","download_url":"https://codeload.github.com/arnobt78/CORS-Proxy-Server-Employee-API/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237446285,"owners_count":19311293,"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":["angular18","backend-server-side","cors-anywhere","cors-proxy","cors-request","crud-api","crud-application","crud-operation","render-deployment","server-side-rendering"],"created_at":"2025-02-06T09:16:47.626Z","updated_at":"2025-10-21T06:32:04.402Z","avatar_url":"https://github.com/arnobt78.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CORS Proxy Server - Employee Management API\n\nA **backend/server-side CORS proxy service** built for the [Employee Management App (Angular 18 frontend)](https://github.com/arnobt78/Employee-Management-App-Angular18). This project demonstrates how to set up and use a CORS proxy server using Node.js and the `cors-anywhere` package to bypass browser same-origin policies, enabling seamless integration between frontend and backend APIs.\n\n---\n\n## Table of Contents\n\n- [Project Summary](#project-summary)\n- [Features](#features)\n- [Project Structure](#project-structure)\n- [Technologies Used](#technologies-used)\n- [Installation \u0026 Setup](#installation--setup)\n- [How to Run](#how-to-run)\n- [Usage Examples](#usage-examples)\n- [API \u0026 Proxy Routes](#api--proxy-routes)\n- [Configuration \u0026 Customization](#configuration--customization)\n- [Deployment Guide](#deployment-guide)\n- [Learning Outcomes](#learning-outcomes)\n- [Keywords](#keywords)\n- [Full Example Code](#full-example-code)\n- [Conclusion](#conclusion)\n\n---\n\n## Project Summary\n\nThis CORS Proxy Server acts as a **bridge between your frontend app and external APIs or backend services** that do not support Cross-Origin Resource Sharing (CORS). It is especially useful in development environments where CORS policies can block legitimate requests from your frontend.\n\nThis backend is designed to be paired with the Angular 18 Employee Management App. It allows your frontend to make API calls to any third-party or backend service as if they were same-origin, enhancing development flexibility and enabling full-stack learning.\n\n---\n\n## Features\n\n- **CORS Proxying:** Bypasses browser CORS restrictions for API requests.\n- **Easy Setup:** Minimal configuration using Node.js and npm.\n- **Customizable:** Modify allowed origins, headers, and other proxy behaviors.\n- **Learning-Oriented:** Clear, simple codebase for educational purposes.\n- **Deployment-Ready:** Can be deployed to cloud platforms like Render.\n\n---\n\n## Project Structure\n\n```\nMock-Server-CORS-Proxy--Employee-Managment/\n├── .gitignore               # Git ignored files\n├── README.md                # Project documentation\n├── package.json             # Project metadata, scripts, dependencies\n├── package-lock.json        # Locked dependency versions\n└── server.js                # Main server/proxy logic\n```\n\n---\n\n## Technologies Used\n\n- **Node.js** (\u003e= v22.12.0)\n- **npm** (Node Package Manager)\n- **[cors-anywhere](https://www.npmjs.com/package/cors-anywhere)** package\n\n---\n\n## Installation \u0026 Setup\n\n### Prerequisites\n\n- Install **Node.js** (version 22.12.0 or later) from [nodejs.org](https://nodejs.org/)\n- Install **npm** (comes with Node.js)\n\n### Steps\n\n1. **Clone the repository:**\n   ```sh\n   git clone https://github.com/arnobt78/Mock-Server-CORS-Proxy--Employee-Managment.git\n   cd Mock-Server-CORS-Proxy--Employee-Managment\n   ```\n\n2. **Install dependencies:**\n   ```sh\n   npm install\n   ```\n\n---\n\n## How to Run\n\nTo start the proxy server, run:\n\n```sh\nnpm start\n```\n\nYou should see:\n```\nCORS Anywhere server running on 0.0.0.0:8080\n```\n\nThis means your proxy is listening on all network interfaces, port 8080.\n\n---\n\n## Usage Examples\n\nTo proxy a request to `http://example.com`, use the following URL in your frontend or browser:\n\n```\nhttp://localhost:8080/http://example.com\n```\n\n**Example in JavaScript (fetch):**\n```js\nfetch('http://localhost:8080/http://example.com')\n  .then(res =\u003e res.json())\n  .then(data =\u003e console.log(data));\n```\n\n---\n\n## API \u0026 Proxy Routes\n\n- `GET /:url` - Proxies the request to the specified URL.\n- `POST /:url` (and other HTTP verbs) - Also proxied.\n\n**How it works:**  \nYou append the target URL you want to reach after your proxy’s root path.  \nExample: To reach `https://api.github.com`, call `http://localhost:8080/https://api.github.com`.\n\n---\n\n## Configuration \u0026 Customization\n\nBy default, the server:\n\n- Allows all origins (`originWhitelist: []`)\n- Requires the `origin` and `x-requested-with` headers\n- Removes `cookie` and `cookie2` headers for security\n\nThese settings are defined in `server.js`:\n\n```js\nconst corsAnywhere = require('cors-anywhere');\nconst host = '0.0.0.0';\nconst port = 8080;\n\ncorsAnywhere.createServer({\n  originWhitelist: [], // Allow all origins\n  requireHeader: ['origin', 'x-requested-with'],\n  removeHeaders: ['cookie', 'cookie2']\n}).listen(port, host, () =\u003e {\n  console.log(`CORS Anywhere server running on ${host}:${port}`);\n});\n```\n\n**To customize:**\n- Edit `originWhitelist` for allowed origins.\n- Change required/removed headers as needed.\n\n---\n\n## Deployment Guide\n\n**To deploy on Render:**\n\n1. Create a new web service on [Render](https://render.com/).\n2. Connect your GitHub repository.\n3. Set the build command to:\n   ```\n   npm install\n   ```\n4. Set the start command to:\n   ```\n   npm start\n   ```\n5. Render will install dependencies and start the server automatically.\n\n---\n\n## Learning Outcomes\n\nBy studying and running this project, you will:\n\n- Understand what CORS is and why it matters in web development.\n- Learn how to set up a proxy server to bypass CORS for educational or development purposes.\n- Gain experience with Node.js server basics and using npm packages.\n- See how to structure a minimal backend service for frontend API consumption.\n- Learn about safe header manipulation and origin controls.\n\n---\n\n## Keywords\n\n```\nCORS, Proxy, Node.js, Backend, API, Proxy Server, Employee Management, Angular, JavaScript, cors-anywhere, Render, npm, HTTP, Cross-Origin, Full Stack, Development, Learning, Server, Security, Origin, Headers, Deployment, Cloud\n```\n\n---\n\n## Full Example Code\n\n### server.js\n\n```js\nconst corsAnywhere = require('cors-anywhere');\nconst host = '0.0.0.0';\nconst port = 8080;\n\ncorsAnywhere.createServer({\n  originWhitelist: [], // Allow all origins\n  requireHeader: ['origin', 'x-requested-with'],\n  removeHeaders: ['cookie', 'cookie2']\n}).listen(port, host, () =\u003e {\n  console.log(`CORS Anywhere server running on ${host}:${port}`);\n});\n```\n\n### package.json (snippet)\n\n```json\n{\n  \"name\": \"mock-server-cors-proxy-employee-managment\",\n  \"version\": \"1.0.0\",\n  \"main\": \"server.js\",\n  \"scripts\": {\n    \"start\": \"node server.js\"\n  },\n  \"dependencies\": {\n    \"cors-anywhere\": \"^0.4.4\"\n  }\n}\n```\n\n---\n\n## Conclusion\n\nThis project provides a practical, learning-focused example of setting up a CORS proxy for web development. It is perfect for students, educators, and full-stack developers who want to understand CORS, backend proxying, and Node.js server basics. Use it as a standalone backend for your Employee Management App or as a template for other CORS-related needs.\n\nFor more details and frontend integration, see the [Employee Management App (Angular 18)](https://github.com/arnobt78/Employee-Management-App-Angular18).\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobt78%2FMock-Server-CORS-Proxy-Employee-Management--ExpressJS-Backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnobt78%2FMock-Server-CORS-Proxy-Employee-Management--ExpressJS-Backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnobt78%2FMock-Server-CORS-Proxy-Employee-Management--ExpressJS-Backend/lists"}