1 00:00:01,980 --> 00:00:06,200 Now that we understand that we need to worry about this whole domain issue inside of get initial props. 2 00:00:06,240 --> 00:00:11,520 We need to figure out whether we are inside the browser or the server when we're trying to make a request 3 00:00:11,520 --> 00:00:14,180 in there so we can adjust the domain accordingly. 4 00:00:14,190 --> 00:00:15,150 So how are we gonna do that. 5 00:00:15,870 --> 00:00:20,580 Well it turns out that next J.S. used to have a really convenient function that we could use to figure 6 00:00:20,580 --> 00:00:25,320 out very easily whether we are in a browser or server environment. 7 00:00:25,320 --> 00:00:28,170 However that little function was removed recently. 8 00:00:28,170 --> 00:00:32,400 So instead we have to rely upon a really kind of silly fallback as you can tell. 9 00:00:32,400 --> 00:00:37,320 I'm a little bit sore that that function was removed out of Next j us but that's life so inside a get 10 00:00:37,320 --> 00:00:38,160 initial props. 11 00:00:38,190 --> 00:00:42,350 Again we have to decide whether we are on the server or the browser to do so. 12 00:00:42,360 --> 00:00:51,430 We're gonna write out if typeof window equals equals equals undefined window is an object that only 13 00:00:51,430 --> 00:00:56,210 exists inside the browser the window object does not exist inside of a No j ust environment. 14 00:00:56,260 --> 00:01:02,980 So if the window variable is undefined inside of well this code that is getting executed somewhere that 15 00:01:02,980 --> 00:01:06,790 must mean we are on the server. 16 00:01:06,940 --> 00:01:14,770 And so any request that we make inside of get initial prompts requests should be made to HDTV and then 17 00:01:14,770 --> 00:01:21,250 that whole really long you are L something like What is it ingress engine X dot ingress dot or dash 18 00:01:21,250 --> 00:01:26,340 engine X blah blah blah all that other stuff we can then add on an L case. 19 00:01:26,410 --> 00:01:38,760 So if window is defined then that means we are on the browser and requests can be made to HDTV or really 20 00:01:38,760 --> 00:01:44,700 we can we can say can be made with a base you are all of just empty string. 21 00:01:44,700 --> 00:01:50,880 And again we will rely upon the browser to put on the base domain or the base rule for us. 22 00:01:50,880 --> 00:01:51,510 So that's it. 23 00:01:51,510 --> 00:01:54,420 That's how we're gonna decide whether we are on the server or the client. 24 00:01:54,960 --> 00:01:59,220 So now that we've established this quick pause right here can make the next video and we're gonna finally 25 00:01:59,580 --> 00:02:00,930 finally make our request.