openMF / web-app

Mifos X Web App is the revamped version of the Mifos X Community App built on top of the Fineract Platform leveraging the popular Angular framework.
https://openmf.github.io/web-app/
Mozilla Public License 2.0
226 stars 511 forks source link

Add instructions to solve CORS issue in readme.md #706

Closed Aaryan-kapur closed 4 years ago

Aaryan-kapur commented 4 years ago

There are no instructions to solve CORS problems

abhaychawla commented 4 years ago

Invalid, there are no CORS issues with the backend.

HarimbolaSantatra commented 1 month ago

Instructions for CORS issue is still needed even on production but I don't know if it should be on Fineract or Mifos README. For those who still struggle with CORS, here's a template to solve it with an Nginx reverse proxy:

server {

    server_name <FINERACT_DOMAIN>;

    set $mifos_domain '<MIFOS_HOST>';

    location / {
    proxy_pass https://<FINERACT_HOST>;
    proxy_set_header Host $host;

    ...

        # Preflighted requests
        if ($request_method = OPTIONS ) {
        add_header 'Access-Control-Allow-Origin' $mifos_domain always;
            add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, OPTIONS' always;
            add_header 'Access-Control-Allow-Headers' 'fineract-platform-tenantid, Authorization, Origin, X-Requested-With, Content-Type, Accept' always;
            add_header 'Access-Control-Allow-Credentials' 'true' always;
            return 200;
        }
    }
}