cors

How do I add CORS to a compojure-api app?

邮差的信 提交于 2021-02-09 09:36:16
问题 How can I add CORS to this code snippet? (def app (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "/route-c" [] "c"))) I would like to use https://github.com/r0man/ring-cors and have tried this, but it did not seem to do anything. I would like to see the response header contain Access-Control-Allow-Origin but it is missing. (-> (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "

response for preflight is invalid (redirect) for aws s3

风格不统一 提交于 2021-02-09 08:38:48
问题 I am trying to upload an image to my Amazon S3 bucket. But I keep getting this CORS error, even though I have set the CORS configuration correctly. This is my CORS configuration: <?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <MaxAgeSeconds>3000</MaxAgeSeconds> <AllowedHeader>Authorization</AllowedHeader> </CORSRule> <CORSRule> <AllowedOrigin>http:/

response for preflight is invalid (redirect) for aws s3

吃可爱长大的小学妹 提交于 2021-02-09 08:28:33
问题 I am trying to upload an image to my Amazon S3 bucket. But I keep getting this CORS error, even though I have set the CORS configuration correctly. This is my CORS configuration: <?xml version="1.0" encoding="UTF-8"?> <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <CORSRule> <AllowedOrigin>*</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <MaxAgeSeconds>3000</MaxAgeSeconds> <AllowedHeader>Authorization</AllowedHeader> </CORSRule> <CORSRule> <AllowedOrigin>http:/

WebAPI - Enable CORS for Subdomains

左心房为你撑大大i 提交于 2021-02-08 15:01:28
问题 I would like to be enable CORS for a web-api application with the following criteria: Allow HTTPS or HTTP for the same site Ignore the SUBDOMAIN - Meaning mysite.com and www.mysite.com are same I would like to do this for multiple sites in an elegant way, rather than putting all the permutations as comma delimited. Thanks in advance! 回答1: Here you go. Adding Git gist if it requires any revisions or bug fixes. public class WildcardOriginCorsPolicy : Attribute, ICorsPolicyProvider { private

Catching “Failed to load resource” when using the Fetch API

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-08 14:44:27
问题 I'm trying to catch a bunch of errors related to the same origin policy when using the Fetch API but without any success: window.onerror = (message, file, line, col, error) => console.log(error) window.addEventListener('error', (error) => console.log(error)) try { fetch('https://www.bitstamp.net/api/ticker/').catch(e => { console.log('Caugth error:') console.log(e) console.log(JSON.stringify(e)) }) } catch (e) { console.log('try-catch') console.log(e) } The errors I want to catch only appear

Catching “Failed to load resource” when using the Fetch API

只愿长相守 提交于 2021-02-08 14:43:12
问题 I'm trying to catch a bunch of errors related to the same origin policy when using the Fetch API but without any success: window.onerror = (message, file, line, col, error) => console.log(error) window.addEventListener('error', (error) => console.log(error)) try { fetch('https://www.bitstamp.net/api/ticker/').catch(e => { console.log('Caugth error:') console.log(e) console.log(JSON.stringify(e)) }) } catch (e) { console.log('try-catch') console.log(e) } The errors I want to catch only appear

Issue with CORS and error and Access-Control-Allow-Origin header

社会主义新天地 提交于 2021-02-08 12:38:09
问题 Hi I cant disable CORS in my project. I use a custom filter and Spring Security Config for the CORS configuration. I have seen this excellent answer: Can you completely disable CORS support in Spring? but when I have tried the below implementation I still get the CORS error: CORS configuration: @Component @Order(Ordered.HIGHEST_PRECEDENCE) class CorsFilter @Autowired constructor() : CorsFilter(configSrc()) { companion object { private fun configSrc(): UrlBasedCorsConfigurationSource { val

Zuul CORS filter doesn't work

徘徊边缘 提交于 2021-02-08 12:10:13
问题 So, basically, the front-end uses reactJS, the back-end Spring Boot (microservices, with zuul acting as the gateway), and of course they can't do anything without CORS stuff. We used this piece of code @Bean public CorsFilter corsFilter() { final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); final CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); config.addAllowedOrigin("*"); config.addAllowedHeader("*"); config

Zuul CORS filter doesn't work

 ̄綄美尐妖づ 提交于 2021-02-08 12:06:26
问题 So, basically, the front-end uses reactJS, the back-end Spring Boot (microservices, with zuul acting as the gateway), and of course they can't do anything without CORS stuff. We used this piece of code @Bean public CorsFilter corsFilter() { final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); final CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); config.addAllowedOrigin("*"); config.addAllowedHeader("*"); config

Ionic 3+ and Node/Express : Http failure response for (unknown url): 0

半世苍凉 提交于 2021-02-08 11:35:54
问题 I've been trying to get data from a local mongodb database, with no success. I've set up a node server using express, cors and mongoose. According to what I've been looking on the internet, this should work : var express = require('express'); var app = express(); var mongoose = require('mongoose'); var cors = require('cors'); app.use(cors({credentials: true, origin: "*", methods: "GET,HEAD,PUT,PATCH,POST,DELETE", preflightContinue:true})); mongoose.connect('mongodb://localhost/cats'); const