1
00:00:00,420 --> 00:00:07,710
Brand bad, and once we have looked at how we can implement the course package to fix our error.

2
00:00:08,010 --> 00:00:10,110
Now let's take a look at the second approach.

3
00:00:10,410 --> 00:00:13,860
The proxy and here's why you see at the moment.

4
00:00:14,280 --> 00:00:21,030
Once we host this somewhere, the server I'm talking about, once we push this up to production, any

5
00:00:21,030 --> 00:00:26,970
front and application can access the data, the API and there's times when you want that.

6
00:00:27,270 --> 00:00:35,970
For example, I have coarse API, which essentially is a resource for all my students in reactors and

7
00:00:35,970 --> 00:00:42,300
JavaScript course, and it's just a bunch of straight up endpoints where you can get some juice on there.

8
00:00:42,750 --> 00:00:51,030
So we're building the project and in order to practice on how to fetch data, javascript or react.

9
00:00:51,360 --> 00:00:53,790
We're hitting these papers.

10
00:00:54,270 --> 00:00:58,680
And of course, this one, yes, I want this one to be publicly available.

11
00:00:59,100 --> 00:01:01,680
But when we're talking about our job, if I one.

12
00:01:02,690 --> 00:01:09,080
If we think about it, do we really want the back end server to be accessible from anywhere?

13
00:01:09,950 --> 00:01:17,780
Like is there any need or only our front end application should have access to our API?

14
00:01:18,530 --> 00:01:24,500
And of course, the answer is, well, kind of doesn't make sense that any front an application can

15
00:01:24,500 --> 00:01:29,870
access our API only our front end application needs to have access throughout.

16
00:01:30,260 --> 00:01:31,460
So that's point number one.

17
00:01:31,890 --> 00:01:36,440
And if you're familiar with course, you're probably thinking, OK, buddy, you don't know what you're

18
00:01:36,440 --> 00:01:42,860
talking about in the course, you can set up the origin so we can pass here some kind of configuration

19
00:01:42,860 --> 00:01:49,100
option where only let's say our frontend can access the code and you're 100 percent correct.

20
00:01:49,310 --> 00:01:58,010
You can set up the config with origin where you explicitly say which domain has access to your data.

21
00:01:58,280 --> 00:02:04,550
But the reason why we're going to go with the proxy option is because it's going to solve more than

22
00:02:04,550 --> 00:02:05,210
just this.

23
00:02:05,900 --> 00:02:13,040
It's essentially will also allow us not to use the full URLs in the front and application.

24
00:02:13,280 --> 00:02:20,720
So that's the second point where I don't want to use my full URL when I'm building the front end application.

25
00:02:21,230 --> 00:02:27,080
I mean, I don't want to go with localhost 5000 and then refactor it to whatever production one.

26
00:02:27,290 --> 00:02:31,590
Again, you can make an argument that you can set it up as a viable yada yada yada yada.

27
00:02:31,730 --> 00:02:32,660
That's not the point.

28
00:02:32,930 --> 00:02:38,930
The idea is that I want to do something like this where I go with four slash, especially if we keep

29
00:02:38,930 --> 00:02:45,200
something in mind eventually, and I'm purposely not covering this in great detail, but eventually

30
00:02:45,650 --> 00:02:51,740
we all use build script to build our production ready react application.

31
00:02:52,100 --> 00:02:53,990
It's just going to be a bunch of static assets.

32
00:02:54,350 --> 00:03:01,490
And then on the server, we'll use express static to serve it as a static asset.

33
00:03:02,150 --> 00:03:05,870
And what that means, we can simply use for its lashes.

34
00:03:06,440 --> 00:03:10,640
But at the moment, we kind of do that in the development, correct?

35
00:03:10,900 --> 00:03:16,730
Again, I'm skipping a little bit ahead, but I'm not covering more details on purpose because I don't

36
00:03:16,730 --> 00:03:17,180
want you to.

37
00:03:17,180 --> 00:03:21,860
Confused what I want you to understand is that we solve both of our issues.

38
00:03:21,860 --> 00:03:30,290
First in the front end will be able to use code like this where we just go with forward slash and whatever

39
00:03:30,300 --> 00:03:33,800
is the endpoint, whether that is auth, whether that is jobs.

40
00:03:34,100 --> 00:03:35,450
And hopefully you get the gist.

41
00:03:35,750 --> 00:03:36,500
That's number one.

42
00:03:36,680 --> 00:03:44,390
And second, we won't need to use the course package on our server altogether because eventually our

43
00:03:44,390 --> 00:03:50,390
front end application, like I said, is going to be hosted on our server anyway.

44
00:03:50,660 --> 00:03:56,570
It's going to be our static asset, so it will have full access to the API.

