0

I'm using superagent v3.8.3 I got Access-Control-Allow-Origin CORS error.

import request from 'superagent'
request(
        APIS.IAMPORT.GET_TOKEN.method,
        APIS.IAMPORT.GET_TOKEN.path()
      )
        .withCredentials()
        .send({
          imp_key: config.iamport.apiKey,
          imp_secret: config.iamport.secretKey
        })
        .end((err, res) => {
          if (err) reject(err)
          else resolve(res.body)
        })

I tried to use .withCredentials(), but it doesn't work. I got this error message from api.

apply?id=21:1 Access to XMLHttpRequest at 'https://api.iamport.kr/users/getToken' from origin 'http://localhost:8080' 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.

However, I can get result when I'm using postman.

I think remove OPTION http method is gonna work. but I'm not sure how can I solve this problem.

How can solve this? thanks.

kkangil
  • 1,616
  • 3
  • 13
  • 27

1 Answers1

0

The issue is not regarding HTTP method. Issue is CORS and has been tried to explain the cause and resolutions in another answer. Please refer the link below:

https://stackoverflow.com/a/54867814/6356369

vcode
  • 453
  • 4
  • 8