1 00:00:00,910 --> 00:00:05,220 The last video we attempted to create a new post but we very quickly ran into a cause your quest aired. 2 00:00:05,270 --> 00:00:08,960 This is a quick reminder on course requests for US requests are an issue. 3 00:00:08,980 --> 00:00:15,470 Anytime that we are looking at some domain or domain with a port or domain with a subdomain that is 4 00:00:15,470 --> 00:00:19,470 different than you are L or the domain that we're trying to make a request to. 5 00:00:19,540 --> 00:00:24,710 So in our case in the browser we are at local host or three thousand and we are trying to make a post 6 00:00:24,710 --> 00:00:28,640 requests to local host port 4000 those ports are different. 7 00:00:28,670 --> 00:00:32,400 And so the course requests policy comes into effect. 8 00:00:32,600 --> 00:00:37,620 The browser is going to automatically reject or prevent any request from being issued from Local three 9 00:00:37,620 --> 00:00:41,250 thousand over to four thousand unless local is 4000. 10 00:00:41,270 --> 00:00:46,970 Our server right here provides a very specific set of headers so in order to get this error right here 11 00:00:46,970 --> 00:00:49,740 to go away there's nothing we could do inside of our browser. 12 00:00:49,790 --> 00:00:53,630 There's no additional configuration we could add to our ReACT app or anything like that to make this 13 00:00:53,630 --> 00:00:54,500 area go away. 14 00:00:54,530 --> 00:01:01,640 We have to do some additional configuration on our server itself let's do that right now to get started 15 00:01:01,820 --> 00:01:03,940 to flip back over to my terminal. 16 00:01:03,980 --> 00:01:09,300 We're going to do this additional configuration on both our post service and the comments service. 17 00:01:09,310 --> 00:01:14,630 It's gonna be a very small little piece of configuration so I'm going to find my turtle Windows running 18 00:01:14,630 --> 00:01:15,700 my post service. 19 00:01:15,770 --> 00:01:22,400 I'm going to stop that server and my comment server as well and then in both of these terminal windows. 20 00:01:22,410 --> 00:01:31,510 So for both posts and for comments I'm going to run npm install force but there's one and there's two 21 00:01:32,660 --> 00:01:33,660 very small package. 22 00:01:33,680 --> 00:01:38,460 All it's going to do is help us get around this course air by setting a header on very specific risk 23 00:01:38,570 --> 00:01:45,540 responses that are going to go back to the browser after that all start up my post service and I will 24 00:01:45,540 --> 00:01:47,330 start back up my comment service. 25 00:01:47,430 --> 00:01:52,850 Very good and I'm going to open up my editor in both these directories and we're going to make use of 26 00:01:52,850 --> 00:02:01,580 that course module that we just installed all first start off with my post service. 27 00:02:01,590 --> 00:02:05,310 Here we go some inside of my posts folder. 28 00:02:05,450 --> 00:02:07,430 I'm in the index not j ust file inside there. 29 00:02:08,780 --> 00:02:11,360 At the very top I'm going to require in course 30 00:02:14,570 --> 00:02:19,840 and I'm going to wire that up to my express application as a middleware so we'll do apps use or is like 31 00:02:19,840 --> 00:02:27,430 so and make sure you call cause as though it were a function I'll save that and I'm going to do the 32 00:02:27,430 --> 00:02:30,590 same thing inside of my comments project as well. 33 00:02:30,700 --> 00:02:35,980 They'll swap back over my comments project here's my comms project again inside of comments 34 00:02:38,680 --> 00:02:41,260 at the very top I'm going to require in course 35 00:02:45,260 --> 00:02:51,170 and again wired up to my app as a middleware and once again I'm gonna make sure that I call the cause 36 00:02:51,200 --> 00:02:57,630 because it is a function save this and we should be good to go now. 37 00:02:57,660 --> 00:02:59,320 Let's flip back over to our browser. 38 00:02:59,490 --> 00:03:00,710 We're gonna try to create a post. 39 00:03:00,720 --> 00:03:07,110 Once again this refund I'm going to refresh the page to get those nasty errors to go a while then enter 40 00:03:07,110 --> 00:03:07,980 in a title here. 41 00:03:08,010 --> 00:03:12,600 So as a first post the minute and there we go. 42 00:03:12,600 --> 00:03:18,630 So my request was issued I got a response of two a one which means that my post was successfully created 43 00:03:19,960 --> 00:03:21,640 Well this is definitely good progress forward. 44 00:03:21,670 --> 00:03:24,880 And we got that little of course error to go away. 45 00:03:24,970 --> 00:03:28,690 We're gonna make sure that if we start to add in any other services to our project we just add in that 46 00:03:28,690 --> 00:03:32,810 course module from the gecko as we start to work on our later project. 47 00:03:32,830 --> 00:03:36,520 So that big project that we're going to work on later on INSIDE the course we're not gonna have to worry 48 00:03:36,520 --> 00:03:40,720 about this cause issue quite so much because there's a couple of little architectural changes we're 49 00:03:40,720 --> 00:03:46,060 gonna add in here so that we will not end up making requests from one year old inside the browser to 50 00:03:46,060 --> 00:03:49,080 some different you or L where our actual API is hosted. 51 00:03:49,090 --> 00:03:54,480 We're gonna make a couple of changes that they're actually co-located so to speak. 52 00:03:54,490 --> 00:03:54,710 All right. 53 00:03:54,740 --> 00:04:00,520 So quick pause right here Mac the next video now that we've got that post creation put together we're 54 00:04:00,530 --> 00:04:04,070 gonna start working on our post office component and then eventually make sure that we can add on the 55 00:04:04,070 --> 00:04:07,100 ability to list out comments and create comments as well. 56 00:04:07,200 --> 00:04:08,270 So I'll see you in just a moment.