• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

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