Cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Issue with Python Dependencies for a Node.js App

Hi,

 

As I am not able to do ssh for manually installing the Python dependencies, I finally deployed my Python app as a separate app and now trying to call it's APIs in my Node App.

 

Getting following error when I make API call to my Python App:

 

Refused to connect to 'https://<mypythonapp>.eu1.mindsphere.io/api' because it violates the following Content Security Policy directive: "default-src 'self' static.eu1.mindsphere.io". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.

 

I have ofcourse included the XSRF-TOKEN from the cookies along with the origin. Do I need to do anything else when I am calling another MindSphere App API?

 

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
Seems you are trying to setup a second application in the developer cockpit; in that case you'd need to setup the CSP configuration in there.

But from what I understood of your use case, you don't need that, you want to call your backend python app from inside the nodejs app; in that case, you can just have a single app in the mdsp dev cockpit. You deploy your two backend apps in your cloudfoundry org/space and refer to the python one from nodejs using the url you get via `cf a`, e.g. `mypythonapp.apps.eu1.mindsphere.io`.

Re: Issue with Python Dependencies for a Node.js App

First of all, I really appreciate your reply on a Saturday Smiley Happy

Actually initially I tried it without configuring on Dev Cockpit, but got the same error, hence I thought I might have to configure it on Dev Cockpit.

When I go back to the URL I get from 'cf a', I still get:

Refused to connect to 'https://pythonbackend-app.apps.eu1.mindsphere.io/api' because it violates the following Content Security Policy directive: "default-src 'self' static.eu1.mindsphere.io". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.

I am calling this API from myorg-mynodejsapp-myorg.eu1.mindsphere.io, so I am not sure if origin needs to be tweaked somewhat? I am using window.location.protocol + '//' + window.location.host in the headers.

I tried with CSRF as well as XSRF token, but CSRF does not exist and with XSRF I still get above error

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
Are you trying to reach the python api from inside the nodejs backend, or the query is being made from the client browser directly to the python api? In one case the communication stays internal to cloudfoundry, in the other you actually need two external endpoints.

I understood that you just needed to trigger the calculation between the nodejs and python backends, so you would trigger the operation on the browser against the nodejs backend, internally it would connect to the python backend, and then get the result for the customer.

Re: Issue with Python Dependencies for a Node.js App

Well, I initially tried to call the Python App API from Node.js front end, but it did not work, so I am now passing the parameters from Node.js Front end (UI) to its Backend and then from Backend to the Python App.

I get a 500 in Node.js Frontend and I get Node.js server logs only upto the point where I make call to python app API.

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
If it was my app I'd:

- ssh to the python backend and make sure that the api calls works in localhost
- then ssh the nodejs backend and try to request from it the queries to the python backend

Almost sure the issue will be in there.

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend

I just learned today that in order to fully enable ssh on a cloudfoundry application, after enabling the settings you have to restart it, might it be that you haven't restarted it? Just wondering, I had not noticed because we restart our apps so often.

https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-apps.html

 

(Another poster had a similar issue)

Re: Issue with Python Dependencies for a Node.js App

Thanks a lot, it does work after restarting the app.

 

It does not allow me to execute "sudo apt-get install pip", but that should be okay now as I have deployed my Python app as a separate app with APIs so that I can access the calculation APIs through my Node.js App.

 

Thanks again for your support.

 

Regards,

Parag

 

Re: Issue with Python Dependencies for a Node.js App

Legend
Legend
Yes, that is to be expected. You are not supposed to perform such kind of post-installation in the system after deployment (and even if you could, you wouldn't be able to automate it in the manifests, you'd have to do that manually or via ssh automation, on any app restart you'd lose the changes). CloudFoundry's model in here is PaaS, not IaaS.

Glad to help!