Code Monkey home page Code Monkey logo

cors-server's Introduction

CORS-Anywhere Server

CORS-Anywhere is a Node.js package that adds CORS headers to a proxied request. This is useful when the API provider does not natively support CORS. Without altering the headers, a request to such a provider would cause an error and prevent the request from being fulfilled.

Tip: You can test out the server in this repo locally by using ports 3000 or 5000 in your application and prepending one of the proxy URLs listed below to your API request like this. You can also test your API endpoints with cors-server in the remote environment here. If you want to host your own server, follow the steps in the Implementation section below.

Proxy URLs

Below are the URLs that can be used for local testing on ports 3000 or 5000.

Firebase: https://proxy-ibmasyzzya-uc.a.run.app/

Fly.io: https://cors-server.fly.dev/

Implementation

The server can be implemented in one of three ways. Is is recommended to use Firebase or Fly.io.

Firebase

Navigate to the functions directory and follow the steps within the README.md therein. This is one of the recommended implementations.

Fly.io

Navigate to the fly.io directory and follow the steps within the README.md therein. This is one of the recommended implementations.

Heroku

Navigate to the heroku directory and follow the steps within the README.md therein. Note that Heroku has withdrawn provision of free dynos as of 28th of November 2022. The cost is now $5 for 1,000 dyno hours per month on the Eco plan that can be used across multiple apps. If this is your only Heroku project, then a potentially much cheaper option is the Basic plan that is only 1¢ per hour. This is billed on a pro rata basis, so you only pay when the server is active. Even if on 24/7, this would only be $7 per month.

cors-server's People

Contributors

isoaxe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cors-server's Issues

When trying to deploy using Firebase Functions, I keep getting an error

Each time I attempt to deploy to Firebase Function I receive an error that says, "Error: An unexpected error has occurred." I have reached out to firebase support, but have not received a response as of yet. Curious, has anyone else seen this? I was able to find this in the logs in firebase.

Unable to retrieve the repository metadata for projects/restored-temecula-mobile-app/locations/us-central1/repositories/gcf-artifacts. Ensure that the Cloud Functions service account has 'artifactregistry.repositories.list' and 'artifactregistry.repositories.get' permissions. You can add the permissions by granting the role 'roles/artifactregistry.reader'.

Getting cors error even after following all the steps you have mentioned on readme

Hello,
I followed all the steps for firebase on your readme, but Im still getting a cors error.
"Access to fetch at 'xyz' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled."
Can you please help me with this?

Help for vercel deployment

I want to ask about how to deploy this in vercel. because i have deployed it in vercel but whenever i request some url it give me the cors error 'access-control' error. please help

Http-Proxy

http-proxy <1.18.1
Severity: high
Denial of Service in http-proxy - GHSA-6x33-pw7p-hmpq
No fix available
node_modules/http-proxy
cors-anywhere *
Depends on vulnerable versions of http-proxy
node_modules/cors-anywhere

2 high severity vulnerabilities

Do you know how to solve this please?

Error 504 on my request

Hi, I was trying to test your firebase URL. But, I an getting error 504 with the server. I used before the repo from CORS Anywhere getting temporary access to his server and works fine, and I created my own in firebase but didn't work either. So, just to be sure, If I prepend your URL to the APIs URL, the server should be making the request to the correct URL (the APIs one)?? I am sorry if I sound like a caveman (I am still learning english). I am using Axios to make the request (not fetch), could be this a problem with the server? Please help me a little... Thanks

Always receiving status 503 error when performing HTTP POST to Firebase Function

Each time I attempt to send a HTTP POST request to my Firebase Function, I receive an error in my browser console, a status 503 error.

I am attempting the post request from a squarespace website in chrome browser. I am sending the exact same information that was sent when using Heroku as 'middleware' for the POST requests from this page. It is a very basic JSON string. Example below.

{ "to": ["ExponentPushToken[dhLJeWNqW61r1ZBUkAwOtA]"], "title": "Hello World! ", "body": "I am Mark Logue, and I made this app!", "sound": "default", "data": {"event": ""} }

The website I am sending the post request from is on my cors-anywhere whitelist with the index.js file.

There are two concerning logs that I found within the Firebase Function (Google Cloud) logs for this function. First when I look at the log for the POST request, it shows in initial Options status of 204, see the log below:

{ "insertId": "6372a16400076996e307afbc", "httpRequest": { "requestMethod": "OPTIONS", "requestUrl": "https://proxy-hwp6dcya3a-uc.a.run.app/https://exp.host/--/api/v2/push/send", "requestSize": "761", "status": 204, "responseSize": "863", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36", "remoteIp": "47.149.74.45", "referer": "https://restoredtemecula.church/", "serverIp": "216.239.36.53", "latency": "1.341490290s", "protocol": "HTTP/1.1" }, "resource": { "type": "cloud_run_revision", "labels": { "configuration_name": "proxy", "location": "us-central1", "revision_name": "proxy-hvnfg", "service_name": "proxy", "project_id": "restored-temecula-mobile-app" } }, "timestamp": "2022-11-14T20:13:24.485782Z", "severity": "INFO", "labels": { "instanceId": "0074e2ccb212737e5aad036cd3cebcfe4d5f35f47d168e939180e59572278e50b0cb6b75be2da34e4a6c16bbab33905987e3d9640d703e97d54f9708a58c14dc9f29", "goog-managed-by": "cloudfunctions" }, "logName": "projects/restored-temecula-mobile-app/logs/run.googleapis.com%2Frequests", "trace": "projects/restored-temecula-mobile-app/traces/ca1ce4c9d9432e0ab47d756bff0cf16c", "receiveTimestamp": "2022-11-14T20:13:24.492659539Z", "spanId": "14113124528369450882", "traceSampled": true }

Second, I receive in the 503 status error both in the logs in firebase function (google cloud) and in my chrome browser (logging the server response for the POST request). Here is the firebase funciton/google cloud log for the 503 status:

{ "insertId": "6372a177000a1e8dbb2702ed", "httpRequest": { "requestMethod": "POST", "requestUrl": "https://proxy-hwp6dcya3a-uc.a.run.app/https://exp.host/--/api/v2/push/send", "requestSize": "1171", "status": 503, "responseSize": "1201", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36", "remoteIp": "47.149.74.45", "referer": "https://restoredtemecula.church/", "serverIp": "216.239.36.53", "latency": "19.114303071s", "protocol": "HTTP/1.1" }, "resource": { "type": "cloud_run_revision", "labels": { "location": "us-central1", "configuration_name": "proxy", "service_name": "proxy", "revision_name": "proxy-hvnfg", "project_id": "restored-temecula-mobile-app" } }, "timestamp": "2022-11-14T20:13:43.663181Z", "severity": "ERROR", "labels": { "instanceId": "0074e2ccb212737e5aad036cd3cebcfe4d5f35f47d168e939180e59572278e50b0cb6b75be2da34e4a6c16bbab33905987e3d9640d703e97d54f9708a58c14dc9f29", "goog-managed-by": "cloudfunctions" }, "logName": "projects/restored-temecula-mobile-app/logs/run.googleapis.com%2Frequests", "trace": "projects/restored-temecula-mobile-app/traces/9dacc5993e58e51bcd37c3c3b8b461e6", "receiveTimestamp": "2022-11-14T20:13:43.670755140Z", "spanId": "17443868335897408337" }

Untitled 5

Lastly, when I attempt to perform the POST request in terminal using CURL, I receive the same response as if I were simply navigate to the link (https://proxy-hwp6dcya3a-uc.a.run.app/https://exp.host/--/api/v2/push/send) in my browser. E.g below shows the CURL command follow by the response, directly copied from terminal and pasted here.

curl -H "Content-Type: application/json" -X POST "https://proxy-hwp6dcya3a-uc.a.run.app/https://exp.host/--/api/v2/push/send" -d '{ "to": "ExponentPushToken[dhLJeWNqW61r1ZBUkAwOtA]", "title":"hello", "body": "world" }' Missing required request header. Must specify one of: origin,x-requested-with%

"Missing required request header. Must specify one of: origin,x-requested-with"... Would love any assistance on this! Thanks in advance!

fastly

How do I make it work on fastly.com?

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.