Try ERPNext Buy Support Partners Foundation

[Tutorial Nginx] Enabling CORS for multiple Domains

i was trying to add more than one domain in nginx , it works with one domain but multiple not
one domain :
add_header 'Access-Control-Allow-Origin' '';
multiple format didn’ works for me … like
add_header 'Access-Control-Allow-Origin' ', ';
add_header 'Access-Control-Allow-Origin' ' ';

the solution was :
Inside frappe bench folder write :
nano config/nginx.conf

write this code before the server block

  map $http_origin $origin_allowed {
     default 0;
     http://localhost:3000 1; 1;
 `#  ... add more allowed origins here`

map $origin_allowed $origin {
  default "";
  1 $http_origin;

and inside the server block you want to open the cors in add this line

            if ($request_method = 'OPTIONS') {
                    add_header 'Access-Control-Allow-Origin' $origin;

as you can see $origin is set by the first code block . that way you can add as many sub domain and domains to call your server .


try with https://

add_header Access-Control-Allow-Origin ""

Can this feature be added to bench command?

bench setup nginx