cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling CORS

jriedl17
Confirmed Champ
Confirmed Champ

Hello. I am creating an ACS ADF App and I want to use a Server which is not on my localhost. I have configured the "app.config.json" file and the "proxy.conf.json" file as described here:'https://community.alfresco.com/community/application-development-framework/blog/2017/06/20/adf-cors-...'. But I still get the Error Messages which you can see in the addings. Do you have any Idea what is wrong in my configurations?

1 ACCEPTED ANSWER

If you just create the build and after you move it in tomcat at this point the proxy configuration is not important anymore because you don't use anymore webpack dev server but you can take a look at how to disable CORS in Apache :

https://community.alfresco.com/community/application-development-framework/blog/2017/06/20/adf-cors-... 

If correctly disabled CORS you should not have any error about CORS, anyway, this is not a suggested configuration for security issues but it could be a good point to understand where are your problems.

This is for sure not an ADF issue but is more an APACHE configuration issues so I suggest you read more about this topic and concentrate your time in solving CORS problems in APACHE Tomcat.

I didn't understand if you never try to run your app on your local machine before. Anyway if you would try and you created your app with the app generator I suggest you use :

npm run start

This is because this command contains inside the configuration for use the webpack proxy :

ng serve --host 0.0.0.0 --disable-host-check --app dev --proxy-config ./demo-shell/proxy.conf.js

but again this proxy configuration is only needed in the local development and is not affecting in any way your deployed app in apache.

View answer in original post

17 REPLIES 17

Cool! no problem!

fcorti
Elite Collaborator
Elite Collaborator

Can you please share the configuration of the proxy?
Where the ADF app leave?
Which URL are you calling from the ADF ?

In the picture I see the target URL is http://alfresco.mbasoft.at:8080 and it seems to be where the Alfresco instance leaves. Is it also where the ADF leave? If not, where does it leave?

1)

proxy.conf.json:

proxy.conf.json

2)

The ADF leaves on my localhost.

3)

I do not directly call URLs. I use the APIService-Methods of ADF to call the Repository of Alfresco.

4) 

On http://alfresco.mbasoft.at:8080 leaves the Alfresco instance and I want to do some requests from my ADF-App running on my localhost

fcorti
Elite Collaborator
Elite Collaborator

Not sure about the target value.
Can you please try with http:;//alfresco.mbasoft.at:8080/alfresco?

I have tried it with this URL but I get the same Error as before.

Do I have to enable CORS if the ADF-App and the Alfresco-Instance leave on the same server? 

ranjeetsi
Star Contributor
Star Contributor

Hi,

I had faced similar situation some time back : please check if this works for you:

On the alfresco backend server - https://community.alfresco.com/external-link.jspa?url=http%3A%2F%2Falfresco.mbasoft.at%3A8080 

you will have to do change in the web.xml to allow a wildcard support for origins.

<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>
And then - whitelist your fronend url at the web proxy layer - if you have .
Also if you have load balancer , web proxy configured before the backend - you need to have the wildcard * , or your frontend url , so that it does not drop your header at any point.
You can run curl commands on urls at each level web proxy ->load balancer -> alfresco to see where the header is dropped .
Since your error is:
==========================
No 'Access-control-allow-origin" header is present on the requested resource(backend)
Thanks!
Alfresco Content Services Certified Engineer (ACSCE)