• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.

Question Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Voovvo

New Pleskian
Server operating system version
Centos 7
Plesk version and microupdate number
18.0.40 Update #1
I'm trying to add external payment method integration to my React app. I'm sending a fetch request to the external payment method's API application, but I'm getting the following error.

This is my fetch code.
JavaScript:
 async getPaymentsAccessToken() {
    const msg = await request<PaymentsAccessTokenResponse>(`https://apitest.crossdomain.com/accesstoken/get`, {
      method: 'POST',
      prefix: undefined,
      mode: 'cors',
      credentials: 'include',
      headers: {
        'Content-Type': 'application/json',
        client_id: this.client.client_id,
        client_secret: this.client.client_secret,
        'Ocp-Apim-Subscription-Key': this.client['Payments-Subscription-Key'],
      },
    });
    return msg;
  }

I got this error
Access to fetch at 'https://apitest.crossdomain.com/accesstoken/get' from origin 'mydomain.com' 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.
None of the settings I made on Plesk Apache and Nginx work.

THIS ARTICLE NOT WORKING... !!!
https://support.plesk.com/hc/en-us/...s-origin-resource-sharing-in-Plesk-for-Linux-
 
Hi,

This is not necessarily a Plesk issue. You better post this on StackOverflow, where the React community can help you:

 
Hi,

This is not necessarily a Plesk issue. You better post this on StackOverflow, where the React community can help you:


But I got this error, Shouldn't this error have something to do with plesk?
Access to fetch at 'https://apitest.crossdomain.com/accesstoken/get' from origin 'mydomain.com' 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.
 
Asking for help here every day isn't helpful. The lack of response on this topic is likely because of the fact this a specific issue to your setup which makes it hard for someone in the community to help you.

You'll have to do the trouble shouting yourself to find a solution to your problem. If you feel it's any issue with Plesk I suggest you contact Plesk support.
 
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "YOUR-DOMAIN.TLD"); // update to match the domain you will make the request from
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});

app.get('/', function(req, res, next) {
// Handle the get for this route
});

app.post('/', function(req, res, next) {
// Handle the post for this route
});


// this might help some one
 
Back
Top