Control Web Panel

WebPanel => CentOS 7 Problems => Topic started by: dinho on February 07, 2022, 05:06:48 PM

Title: Api rest CWP with error in CORS
Post by: dinho on February 07, 2022, 05:06:48 PM
I'm developing an interface that uses the Api rest of the CWP, however, even putting % in the origin of the Apimanager settings, it still has CORS errors.
Does anyone know how to disable cors for API?
Title: Re: Api rest CWP with error in CORS
Post by: rcschaff on February 08, 2022, 01:56:20 PM
First, There is no way to disable CORS in modern browsers...

Did you try * instead of %?  CORS will read * as allow any.  (Please try this first)

Aside from that, you may need to tweak settings in the API config files

vi /usr/local/cwpsrv/conf.d/api.conf

Add the following line right after error_log
add_header Access-Control-Allow-Origin *;

Please note that you will have to fix this each time you update CWP.

Once that is done

/usr/local/cwpsrv/bin/cwpsrv -s reload