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

Getting CORS error for verification. #19

Open
Suraez opened this issue Feb 23, 2021 · 6 comments
Open

Getting CORS error for verification. #19

Suraez opened this issue Feb 23, 2021 · 6 comments

Comments

@Suraez
Copy link

Suraez commented Feb 23, 2021

i am getting cors error while making POST request to merchant API for verification. And when i try to use reverse proxy i.e. https://cors-anywhere.herokuapp.com , i got 403 unuathorized error

Access to XMLHttpRequest at 'https://khalti.com/api/v2/payment/verify/' 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.

while using reverse proxy
Failed to load resource: the server responded with a status of 403 (Forbidden)

@aaeronn
Copy link
Contributor

aaeronn commented Feb 23, 2021

Are you trying to communicate api from client side ??

@Suraez
Copy link
Author

Suraez commented Feb 23, 2021

yeah

@Suraez
Copy link
Author

Suraez commented Feb 23, 2021

I tried to implement from the server but no luck. Got this

xhr.js:184 GET http://localhost:7655/khalti/M6aERNTpGNk9wukyi8n22a/1000/my_secret_key (Internal Server Error)

above is my own API which eventually calls merchant API with token, amount and secret key in req.params. I extract these from req.params and call the API as:

let data = {
        token: req.params.token,
        amount: req.params.amount,
      };

    let config = {
    headers: {
        Authorization: "MY-TEST-SECRET-KEY",
    },
    };
    axios
        .post(
        "https://khalti.com/api/v2/payment/verify/",
        data,
        config
        )
        .then((response) => {
        console.log(response.data);
        console.log("Yay!, It's done");
        })
        .catch((error) => {
        console.log(error);
        });

@inquisitive-stha
Copy link

Any update on this??

@Abhinav0057
Copy link

any update?

@Roopaish
Copy link

geez, it's still an open issue

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

5 participants