Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,130 --> 00:00:05,930
Now, before we dive into any demo or any code
2
00:00:05,930 --> 00:00:10,400
let's understand how React apps do talk to databases.
3
00:00:10,400 --> 00:00:13,480
And as you can tell, by the title of this slide,
4
00:00:13,480 --> 00:00:16,850
it's not working as you maybe thought it works
5
00:00:16,850 --> 00:00:21,110
because React apps, or in general browser-side apps,
6
00:00:21,110 --> 00:00:24,140
browser-side code, so JavaScript code
7
00:00:24,140 --> 00:00:25,660
running in the browsers
8
00:00:25,660 --> 00:00:29,720
should never directly talk to a database.
9
00:00:29,720 --> 00:00:33,560
So, if you have a React app and then some kind of database,
10
00:00:33,560 --> 00:00:37,890
a SQL database, a NoSQL database like MongoDB
11
00:00:37,890 --> 00:00:41,660
it does not matter if you have such a database running
12
00:00:41,660 --> 00:00:44,540
on some database server then, of course,
13
00:00:44,540 --> 00:00:46,740
you might want to fetch and store some data
14
00:00:46,740 --> 00:00:49,600
and you might wanna establish a connection,
15
00:00:49,600 --> 00:00:51,480
but that's not what you should do
16
00:00:51,480 --> 00:00:55,890
and that's not what you'll ever see out there in the wild
17
00:00:55,890 --> 00:01:00,750
unless it's a highly insecure and bad written application.
18
00:01:00,750 --> 00:01:05,150
Because if you would directly connect to a database,
19
00:01:05,150 --> 00:01:07,570
if we leave a site that this will technically
20
00:01:07,570 --> 00:01:09,930
be challenging, but if you would do that,
21
00:01:09,930 --> 00:01:13,010
if you would directly connect to a database server
22
00:01:13,010 --> 00:01:16,440
from inside your client-side, your browser-side
23
00:01:16,440 --> 00:01:19,280
JavaScript code, you would expose your
24
00:01:19,280 --> 00:01:22,240
database credentials in that code.
25
00:01:22,240 --> 00:01:26,330
Because you must never forget that all JavaScript code
26
00:01:26,330 --> 00:01:30,130
running in the browser can be accessed and read,
27
00:01:30,130 --> 00:01:31,860
not just by the browser,
28
00:01:31,860 --> 00:01:34,470
but also by the users of your website.
29
00:01:34,470 --> 00:01:36,740
Simply open up the developer tools
30
00:01:36,740 --> 00:01:39,250
and you can view all the code there.
31
00:01:39,250 --> 00:01:43,050
This generally is no problem, and attached you'll find
32
00:01:43,050 --> 00:01:46,610
a more detailed article and video which I created on this.
33
00:01:46,610 --> 00:01:48,630
But, of course, it will become a problem
34
00:01:48,630 --> 00:01:52,770
if you expose security relevant details in your code.
35
00:01:52,770 --> 00:01:56,740
For example, credentials that allow access to a database.
36
00:01:56,740 --> 00:01:59,480
In addition, directly connecting to a database
37
00:01:59,480 --> 00:02:02,890
could also bring other problems like performance issues
38
00:02:02,890 --> 00:02:06,970
but the security problem is the biggest problem of all.
39
00:02:06,970 --> 00:02:10,550
So, therefore, instead of directly talking to a database
40
00:02:10,550 --> 00:02:13,100
from inside your reactive code,
41
00:02:13,100 --> 00:02:15,550
you always take another route.
42
00:02:15,550 --> 00:02:19,780
You have a Backend application running on another machine
43
00:02:19,780 --> 00:02:21,120
not running in the browser,
44
00:02:21,120 --> 00:02:23,590
but running on some server out there,
45
00:02:23,590 --> 00:02:26,550
maybe on the same server as the database,
46
00:02:26,550 --> 00:02:29,260
often on a different server, though.
47
00:02:29,260 --> 00:02:31,670
Now, this Backend application can be written
48
00:02:31,670 --> 00:02:34,450
with any server-side language of your choice,
49
00:02:34,450 --> 00:02:39,450
NodejS, PHP, ASP.NET, everything is possible.
50
00:02:40,000 --> 00:02:42,000
And it's this Backend application
51
00:02:42,000 --> 00:02:44,510
which will do the talking to the database,
52
00:02:44,510 --> 00:02:48,300
because you can safely store and use database credentials
53
00:02:48,300 --> 00:02:51,315
on the Backend application since that Backend code
54
00:02:51,315 --> 00:02:54,280
can't be viewed by your users.
55
00:02:54,280 --> 00:02:56,580
It's on a different server and the users
56
00:02:56,580 --> 00:02:58,993
of your website will never see that code.
57
00:02:59,920 --> 00:03:02,010
And, therefore, the reactive will then talk
58
00:03:02,010 --> 00:03:05,870
to that Backend server, to that Backend API, typically,
59
00:03:05,870 --> 00:03:09,610
which is a server which exposes different URLs
60
00:03:09,610 --> 00:03:11,360
requests can be sent to
61
00:03:11,360 --> 00:03:13,740
and we're going to see this throughout this section.
62
00:03:13,740 --> 00:03:17,210
And then you have a safe connection to the database
63
00:03:17,210 --> 00:03:19,930
because the credentials are on this Backend app,
64
00:03:19,930 --> 00:03:22,060
and for talking to the Backend app
65
00:03:22,060 --> 00:03:25,650
no security relevant details are needed.
66
00:03:25,650 --> 00:03:28,160
This is how this works, and this is what we're going to see
67
00:03:28,160 --> 00:03:30,433
in action in this course module.
5565
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.