The last video we attempted to create a new post but we very quickly ran into a cause your quest aired.
This is a quick reminder on course requests for US requests are an issue.
Anytime that we are looking at some domain or domain with a port or domain with a subdomain that is
different than you are L or the domain that we're trying to make a request to.
So in our case in the browser we are at local host or three thousand and we are trying to make a post
requests to local host port 4000 those ports are different.
And so the course requests policy comes into effect.
The browser is going to automatically reject or prevent any request from being issued from Local three
thousand over to four thousand unless local is 4000.
Our server right here provides a very specific set of headers so in order to get this error right here
to go away there's nothing we could do inside of our browser.
There's no additional configuration we could add to our ReACT app or anything like that to make this
area go away.
We have to do some additional configuration on our server itself let's do that right now to get started
to flip back over to my terminal.
We're going to do this additional configuration on both our post service and the comments service.
It's gonna be a very small little piece of configuration so I'm going to find my turtle Windows running
my post service.
I'm going to stop that server and my comment server as well and then in both of these terminal windows.
So for both posts and for comments I'm going to run npm install force but there's one and there's two
very small package.
All it's going to do is help us get around this course air by setting a header on very specific risk
responses that are going to go back to the browser after that all start up my post service and I will
start back up my comment service.
Very good and I'm going to open up my editor in both these directories and we're going to make use of
that course module that we just installed all first start off with my post service.
Here we go some inside of my posts folder.
I'm in the index not j ust file inside there.
At the very top I'm going to require in course
and I'm going to wire that up to my express application as a middleware so we'll do apps use or is like
so and make sure you call cause as though it were a function I'll save that and I'm going to do the
same thing inside of my comments project as well.
They'll swap back over my comments project here's my comms project again inside of comments
at the very top I'm going to require in course
and again wired up to my app as a middleware and once again I'm gonna make sure that I call the cause
because it is a function save this and we should be good to go now.
Let's flip back over to our browser.
We're gonna try to create a post.
Once again this refund I'm going to refresh the page to get those nasty errors to go a while then enter
in a title here.
So as a first post the minute and there we go.
So my request was issued I got a response of two a one which means that my post was successfully created
Well this is definitely good progress forward.
And we got that little of course error to go away.
We're gonna make sure that if we start to add in any other services to our project we just add in that
course module from the gecko as we start to work on our later project.
So that big project that we're going to work on later on INSIDE the course we're not gonna have to worry
about this cause issue quite so much because there's a couple of little architectural changes we're
gonna add in here so that we will not end up making requests from one year old inside the browser to
some different you or L where our actual API is hosted.
We're gonna make a couple of changes that they're actually co-located so to speak.
All right.
So quick pause right here Mac the next video now that we've got that post creation put together we're
gonna start working on our post office component and then eventually make sure that we can add on the
ability to list out comments and create comments as well.
So I'll see you in just a moment.