Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS Error, While Using in ReactJS Application #3

Closed
asmitsirohi opened this issue Sep 15, 2021 · 4 comments
Closed

CORS Error, While Using in ReactJS Application #3

asmitsirohi opened this issue Sep 15, 2021 · 4 comments

Comments

@asmitsirohi
Copy link

I'm trying to use this api in my ReactJS application, and facing CORS error.

Code:
var data = JSON.stringify({
code: public class program{ public static void main(String [] args){ System.out.println("Hello"); } },
language: "java",
input: "",
});

  const response = await axios.post(
    "https://codexweb.netlify.app/.netlify/functions/enforceCode",
    {
      data: data,
    },
    {
      headers: {
        "access-control-allow-origin": "*",
        "Content-type": "application/json; charset=UTF-8",
      },
    }
  );

Error ScreenShot:
image

@Jaagrav
Copy link
Owner

Jaagrav commented Oct 24, 2021

This api works only in backend, for example with nodejs, in order to use it in front end you need to add this URL as a prefix https://cors-anywhere-jaagrav.herokuapp.com/https://codexweb.netlify.app/.netlify/functions/enforceCode and it should work

@asmitsirohi
Copy link
Author

Thanks....It helps a lot.

@Alex-Beep-Cao
Copy link

Really Helpful, thank you very much!!!

@Jaagrav
Copy link
Owner

Jaagrav commented Jun 25, 2022

The API now supports No CORS requests so you don't need to follow the above comment any more. Check out the new docs, https://github.com/Jaagrav/CodeX-API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants