Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emrd/nodejs-decline-requests-from-browser
https://github.com/emrd/nodejs-decline-requests-from-browser
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/emrd/nodejs-decline-requests-from-browser
- Owner: EmrD
- Created: 2024-08-17T21:02:37.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-17T21:09:17.000Z (3 months ago)
- Last Synced: 2024-08-17T22:23:34.523Z (3 months ago)
- Language: Nix
- Size: 1.35 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node.js API Project
This project is a Node.js API application that blocks access from browsers. Requests coming from browsers are blocked by checking specific `User-Agent` headers, and a 403 Forbidden error is returned to the user. Non-browser clients (e.g., `curl`, Postman) can access the API without issues.
## Getting Started
### Prerequisites
You need the following software installed on your machine to run this project:
- Node.js (>= 12.x)
- npm or yarn### Installation
After cloning the repository, install the dependencies using the following commands:
```bash
git clone REPO_URL
cd FOLDER_NAME
npm install
node index.js
```### Testing
To test the API go to ```http://localhost:3000/ANY_ENDPOINT``` on your browser. You must get this message: "You can NOT access this API from a browser." To test from cURL; run:
```bash
curl http://localhost:3000/api/data
```
You'll get this response: ```Permission Accepted from curl/YOUR_CURL_VERSION```