From the course: Angular: Creating and Hosting a Full-Stack Site

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Avoid CORS errors

Avoid CORS errors

From the course: Angular: Creating and Hosting a Full-Stack Site

Start my 1-month free trial

Avoid CORS errors

- [Instructor] So, we've got our front-end set up to make requests to our back-end. However, if we were to try and make an actual request to our server now, we'd end up getting something called a CORS error telling us that the back-end has blocked our request. CORS errors are security related errors that are very common in local development environments. And they happen when in our case, we try to make a request from one origin to another. In order to get around this for local development purposes, we need to set up something called a Proxy. And to do that, there are a few things we need to add to our project. The first thing we need to do is in the root of our app directory, we need to create a new file. And we're going to call that file "proxy.config.json". And this will contain some configuration info that our app can use to set up a Proxy for our requests. Here's what that'll look like. We're going to have a JSON…

Contents