Giter Club home page Giter Club logo

njs-ergastf1api's Issues

Open to pull requests?

Thanks for your work on this. I have forked the repository with the intention of decoupling the API from the database.

Are there any features in the PHP implementation that are missing? I could implement them if there are.

CORs not supported

AJAX calls via axios fail due to cors issues.

Request

curl 'http://localhost:8080/races?year=2021' \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'DNT: 1' \
  -H 'Origin: http://localhost:3000' \
  -H 'Pragma: no-cache' \
  -H 'Referer: http://localhost:3000/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-site' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' \
  -H 'sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --compressed

Response Headers

Request URL: http://localhost:8080/races?year=2021
Request Method: GET
Status Code: 400 
Referrer Policy: strict-origin-when-cross-origin

CORS issue while loading in React Frontend

First of all, thank you for this node.js based API of ErgastAPI.

I'm successfully running the API in Docker using domain localhost:8080
Unfortunately the REST API is blocked by CORS while loading it in my react app.

Exact error is:
VM1514:1 Access to XMLHttpRequest at 'localhost:8080/drivers' from origin 'http://localhost:3000' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

This is my code so far. I've already tried to add CORS header but that doesn't effect anything.
Can you please help me out a bit?

function App() {
 useEffect(() => {
    let ignore = false;

    async function fetchData() {
      const result = await axios("localhost:8080/drivers", {
        headers: {
          "Access-Control-Allow-Origin": "*"
        }
      });
      if (!ignore) setData(result.data);
      console.log(result);
    }

    fetchData();

  });
}

TypeScript NestJS implementation

Hi Davide,

Not sure of the best way to contact you so I hope you see this.

I have taken the liberty to create a NodeJS implementation based on the one you have here.

https://github.com/StraightOuttaCrompton/ergast-api

My goal has been to use industry best practices to help make the api easier to maintain a develop. It is written in TypeScript and uses the NestJS framework. I have also written some test to ensure that the migration has been done succesfully with no regressions.

I am hoping you could take a look and let me know your thoughts.

Many thanks,
StraightOuttaCrompton

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.