Trouble-shooting CORS in Play Framework 2.4.x

前端 未结 7 701
没有蜡笔的小新
没有蜡笔的小新 2020-12-10 14:55

I have a java play framework 2.4.x web app providing a JSON/HTTP API. When I run my front-end HTML/JS file:///Users/nize/tmp/index.html calling the API on

7条回答
  •  猫巷女王i
    2020-12-10 15:40

    filters = "filters.Filters"
    
    
    play.filters {
    
      cors {
    
        # The allowed origins. If null, all origins are allowed.
        allowedOrigins = null
    
        # The allowed HTTP methods. If null, all methods are allowed
        allowedHttpMethods = null
    
        # The allowed HTTP headers. If null, all  headers are allowed.
        allowedHttpHeaders = null
      }
    
    }
    
    
    
    public class Filters implements HttpFilters {
    
        @Inject
        private CORSFilter corsFilter;
    
        public EssentialFilter[] filters() {
            return new EssentialFilter[] {
                corsFilter.asJava()
            };
        }
    
    }
    

提交回复
热议问题