Search code examples
angularjscorscloud-foundryswisscomdev

Static Buildpack throws CORS 405 Method not allowed for JSON file


I am using Swisscom Application Cloud (based on Cloudfoundry). I deployed an app usign Static Buildpack and the idea is that this app delivery a JSON file. As soon as I try to access the remote JSON file from a AngularJS application with a GET call, I get a 405 Method Not Allowed on the OPTIONS call. I think it is a CORS issue. Is there anyone out there having an idea how I can make sure that CORS is handled properly by my Static Buildpack app? Is there anyway I can define this in my manifest.yml?

Greets, Marc


Solution

  • Without having tried it myself, I guess you can achieve this by providing a custom nginx configuration (http://docs.cloudfoundry.org/buildpacks/staticfile/#custom_nginx_configuration) containing CORS settings.

    Nginx CORS examples: https://serverfault.com/questions/162429/how-do-i-add-access-control-allow-origin-in-nginx/