GithubHelp home page GithubHelp logo

qzz0518 / nextjs-cors-anywhere Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deybyr647/nextjs-cors-anywhere

0.0 1.0 0.0 153 KB

A remake of the CORS-Anywhere project with a light front-end, to visualize API endpoints

Home Page: https://nextjs-cors-anywhere.vercel.app

License: MIT License

JavaScript 4.67% TypeScript 91.24% CSS 4.09%

nextjs-cors-anywhere's Introduction

nextjs-cors-anywhere

This is my twist on vercel-cors-anywhere using NextJS API Routes.

This tool itself is based on cors-anywhere, with deployment to Vercel being possible

Caching & Header Forwarding

As mentioned in the original repository, requests are cached for 10 minutes if the URL is the same

Header Forwading is (still) not available

My Added Twists:

  • Similar logic but with NextJS API Routes

  • Information about the project and how it works on a landing page

  • A way to preview API responses via landing page

Fixes/Improvements on original repository

  • API Responses are displayed within an iframe as raw JSON, rather than plaintext in HTML

  • Fixed issue where URL Params were being truncated during request time

    • e.g. /api?endpoint=https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=APIKEY&radius=16094&keyword=restaurant&location=43.66542,-73.74970

    • The endpoint param's expected value would be: https://maps.googleapis.com/maps/api/place/nearbysearch/json? key=APIKEY&radius=16094&keyword=restaurant&location=43.66542,-73.74970

    • Instead, URL params from the endpoint URL would be truncated out. So the endpoint param would actually look like this: https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=APIKEY

    • This truncating of URL params would lead to HTTP 400 errors, since there were missing params of course

Usage

https://nextjs-cors-anywhere.vercel.app/api?endpoint=url

url --> API Endpoint/URL

Examples

https://nextjs-cors-anywhere.vercel.app/api?endpoint=https://www.deybyr647.com/api/projects?name=RecycleIT

Example code with Fetch in JavaScript

nextjs-cors-anywhere's People

Contributors

deybyr647 avatar eai04191 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.