CORS blocked OCS api using Docker

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 24
Operating system and version (eg, Ubuntu 20.04): Linux
Apache or nginx version (eg, Apache 2.4.25): Using Docker
PHP version (eg, 7.4): 8

The issue you are facing:

When trying to access OCS Api i get response:
Access to XMLHttpRequest at ‘http://server:8080/ocs/v2.php/apps/dav/api/v1/direct’ 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. We are using Docker.

How do i enable access to this api from other domains?
When using webdav it works perfectly but only with OCS i get cors error.