Posts

Showing posts with the label cors

Font files are blocked by CORS policy

Image
Font files are blocked by CORS policy I want to build a server accelerated by a CDN provider, which serves static files for my other websites. I decide to use https://www.funfun.org.cn, then for example https://www.funfun.org.cn/libs/font-awesome.min.css and https://www.funfun.org.cn/libs/octicons.min.css should be able to be used by other websites. However, when I test this server by my website in localhost, I see the following errors: For example, Access to Font at 'https://www.funfun.org.cn/libs/octicons.woff' from origin 'https://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost:3000' is therefore not allowed access. Other errors are similar and for https://www.funfun.org.cn/fonts/fontawesome-webfont.woff2?v=4.4.0 and https://www.funfun.org.cn/libs/octicons.ttf , etc. https://www.funfun.org.cn/fonts/fontawesome-webfont.woff2?v=4.4.0 https:/...

405 method not allowed using Tomcat

405 method not allowed using Tomcat I am new to web development and having this issue for some time. I tried a lot of things that were suggested on SO and elsewhere, but no luck. Anyways, i'll explain what I am doing. I am trying a simple exercise where I have a simple HTML page that accepts a city name and on clicking the submit button, will show me the weather of that city. The HTML code is as below: <body> <form> <div> <label for="city">City</label> <input id="city" type="text" name="city"> </div> <div> <input id="submitButton" type="button" name="submitButton" value="Get weather!" onclick="send()"> </div> </form> <script type="text/javascript" src="CityWeather.js"></script> </body> This HTML file makes a call...

ReactJS API Data Fetching CORS error

ReactJS API Data Fetching CORS error I've been trying to create a react web app for a few days now for my internship and I've encountered a CORS error. I am using the latest version of reactJS, and placing this in the create-react-app , and below is the code for fetching: create-react-app componentDidMount() { fetch('--------------------------------------------',{ method: "GET", headers: { "access-control-allow-origin" : "*", "Content-type": "application/json; charset=UTF-8" }}) .then(results => results.json()) .then(info => { const results = info.data.map(x => { return { id: x.id, slug: x.slug, name: x.name, address_1: x.address_1, address_2: x.address_2, city: x.city, state: x.state, postal_code: x.postal_code, country_code: x.country_code, phone_number: x.phone_number, } }) th...

Handling CORS when developing from localhost using REST APIs - Streamlabs API

Image
Handling CORS when developing from localhost using REST APIs - Streamlabs API I'm sure this question will get flagged in some manner, however hours of searching has prompted no usable information. Many projects require me to use various APIs. The current project uses the Twitch and Streamlabs API. When trying to access the /authorize endpoints, I'm hit with a CORS policy restriction. This is because my referer/origin is localhost. My question lies in how others set up their environment for this not to be an issue. I understand why CORS is blocking me (to an extent), but what I don't understand is how I'm expected to work away from my production server if localhost has a blanket restriction. localhost I have as well tried manipulating headers in fetch as well as using [no-cors] , but no avail here either. Any ideas? [no-cors] // Starts authorization getAuth() { const data = fetch (`https://streamlabs.com/api/v1.0/authorize?client_id=${clientID}&response_type...