Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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...
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.
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
Thanks for your answer again. And sorry for the delay. I have been digging some bits.
Well, the cross-domain requests should be allowed in my schema, since I have the domains already set in my server and I tested it with another browser (native Chrome browser and Firefox), and the same schema works on those browsers. However, if you see my original question, the pre-flight request, that should send an OPTIONS request to the server, to retrieve the allowed origins, is not even fired. Therefore, I am assuming that this has to do with Adobe's chromium blocking any requests that should not be blocked at all.
Copy link to clipboard
Copied
Also,
I created a node js server inside another 'hidden' extension and was able to make requests without any issues to the server. As I am trying to work with vueJs, someone quoted that if I want to ship everything in one package, I will need to use a Server Side Rendering (SSR) framework, as Nuxt.
Copy link to clipboard
Copied
Hello! thread moved from Labs to Exchange
Copy link to clipboard
Copied
Did you ever figure this out? I'm running into the same issue.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now