Skip to main content
Participant
November 28, 2019
Question

REST API Calls from inside CEP are canceled

  • November 28, 2019
  • 4 replies
  • 2353 views

Hello all!

 

It's been 2 days since I'm stuck in this problem. I'll describe it:

 

I have a CEP extension inside Adobe InDesign 2020, using CEP 8.0, inside a Windows 10 Oracle virtualbox machine, that is inside a Linux native computer. In this extension, I am using VueJS (that proved itself  (to me) working good inside CEP env) and within that single-page-application I am using the superagent library (can be found here https://www.npmjs.com/package/superagent) to fetch some data from a REST API service hosted inside my linux machine. 

Thefore, I have:
A Linux machine running a REST API service.
A Windows inside a virtual machine with Adobe Indesign and an extension trying to access the REST API Service using superagent library.

I hope I was clear enough. 

 

And when I hit the button to fire up the request, I get this error in the debugger (google chrome):

 

Error: Request has been terminated
Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.
    at Request.crossDomainError (client.js:655)
    at XMLHttpRequest.xhr.onreadystatechange (client.js:758)

 


When I look into the network tab on the chrome tools debugger thing, it shows up the 'canceled' status for the request. I.e., it is just not sending the request. The browser (CEP chromium engine) is just blocking it.

 

I thought it would be a CORS problem. But then I runned the application inside the normal chrome browser and it worked perfectly. Also, my server, as a open REST API config, accepts all origins.

 
The question is: why is the request being blocked? Am I not allowed to fire up requests within the application? Do I need something else for it like, for example, an embedded nodejs server to do that?

I appreciate any thoughts that might come up about this.

 

Best Regards,
An old Owl.

This topic has been closed for replies.

4 replies

Participant
February 5, 2020

I had this same issue and this post had my solution.

 

The solution:

e.preventDefault();

 

In my case, my form was being submitted and right after my ajax call happened the page would refresh, thus cancelling my ajax request.

Participant
February 5, 2020

Did you ever figure this out? I'm running into the same issue.

PECourtejoie
Community Expert
Community Expert
January 15, 2020

Hello! thread moved from Labs to Exchange

GNDGN
Inspiring
December 2, 2019

The communication between cross-domain services is indeed blocked for security reasons by Chromium. I stronlgy suggest to rely on node.js-servers with a webhook sender and receiver implemented. I made good experiences with this module: https://www.npmjs.com/package/node-webhooks

____________________Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5
Participant
December 2, 2019

Thanks for your answer, gndgn.

Can you comment about this link? https://github.com/Adobe-CEP/Getting-Started-guides/tree/master/Network%20requests%20and%20responses%20with%20Fetch#request-and-display-the-weather-for-a-city

In this getting-started tutorial, no NodeJs server application is being executed and the request is done through fetch API. I tried the same approach by using fetch API, and superagent and axios as well. Neither of those cases worked. I really wonder why it works in the tutorial but it won't work for me using vueJs + axios/superagent/fetch. 

Do I need to create a new CEP extension to run a NodeJs server and call this extension (open it) from the other extension? I thought that because CEP has a nodeJs integrated, I wouldn't need to do it. But it seems one thing has nothing to do with the other.
  

GNDGN
Inspiring
December 3, 2019

Please check the header of the responder if cross-domain requests are allowed.
(More: https://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work)

____________________Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5