http requests got blocked by CORS policy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2022 03:48 AM
I'm trying to make a get request from ADF to Alfresco comunity 7.0. Here is the code:
export class MydatatableComponent implements OnInit { constructor() { const alfrescoApi = new AlfrescoApi({ hostEcm: 'http://localhost:8080' }); const peopleApi = new PeopleApi(alfrescoApi); const opts = { 'skipCount': 56, /* | The number of entities that exist in the collection before those included in this list. If not supplied then the default value is 0. */ 'maxItems': 56 }; peopleApi.listPeople().then((data) => { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); }
and here is the error I get from the console:
Access to XMLHttpRequest at 'http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/people' from origin 'http://localhost:4200' 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.
and this my proxy.conf.js
module.exports = { "/alfresco/*": { "target": "http://localhost:8080", "secure": false, "changeOrigin": true } };
I did download enablecors-1.0 and copied it to modules/platform but it didn't work.
What is the problem and how I can fixit?
PS: I also tried to use apiService.getInstance().webScript.executeWebScript
and it didn't work.
Thank you in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-17-2022 04:00 AM
Try using this setting in Alfresco Repository:
csrf.filter.enabled=false
You may add this property to alfresco-global.properties

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2022 04:21 AM
I did add csrf.filter.enabled=false to my alfresco-global.properties and got the same error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2022 09:45 AM
Some additional info can be found here: https://hub.alfresco.com/t5/application-development/adf-cors-solving-strategies/bc-p/311055#M272
(ACSCE, AWS SAA, Azure Admin)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2023 05:22 AM
You proxy target needs to point to a remote ACS. So that your app calls localhost that is redirected by proxy. In your example, your proxy is having incorrect target and points to self
