In this video, learn how to deploy the code for the servers you will use in this course.
- [Lecturer] The same-origin policy comes into play when resources are loaded from different origins. So to work along with the videos in this course you'll need to deploy the exercise files to two different web servers with node environments. Ideally at two different domains, though you can complete almost everything using two subdomains of the same domain. Because some same-origin policies treat local host as a special case, you won't always get the same results if you simply run two web servers locally. However, if you don't have access to remote servers, you'll still be able to accomplish some of the tasks in this course using a local HTTP server. The exercise files contain folders for each chapter as well as a servers folder. The servers folder contains a resources folder and a site folder. Site serves the front-end HTML files while resources is a sort of CDN, hosting assets like images and fonts. Because many of the files in the servers contain links to each other, you'll need to customize all domain references in files on both servers to use the domain names of your servers. In the exercise files all the URLs include placeholders for the domain names to make it easy for you to globally search and replace, which you can do pretty easily in any code editor. So here we can see this reference which is just the word RESOURCES all caps, surrounded by two sets of square brackets and that you'll replace with the domain name of your resources server and likewise for the site server. So for instance, if I'm using the domain name example.com for the site server and 794147-1.youcanlearnit.net for the resources server in Visual Studio Code I'll open the search box and I'll search on square bracket, square bracket, all caps SITE close those square brackets. And then I'll replace all instances with example.com, press Enter and we find 23 results. And so Visual Studio Code has this Replace All button and just click that. Confirm. And everything's replaced. And likewise, I can search for RESOURCES all caps in two sets of square brackets. And for this one I've got a more complicated domain name. 794147 dash 1 dot youcanlearnit dot net, there's an N in there. And then if I press Enter it finds a whole bunch of results and then I click the Replace All button, confirm that I want to replace all and now we can see that that domain is replaced throughout. So I've still got the correct path, based on the way those server folders are structured, but now it's going to the actual domain name that I'm going to be use. And so now my files are ready to use with my domains. You want to follow your web host's instructions for deployment In many of the videos in this course my sites are deployed to different Heroku instances. Heroku maintains thorough documentation on deploying with Git, which is the method I use throughout the course. Remember that you want to deploy the site and resources folders to two separate domains or subdomains if you're using Heroku. Hosting both folders as a single app with different subfolders won't work for most of the videos in this course. In addition to the servers folder the exercise files also contains a folder for each chapter with a subfolder for each video that makes changes to files. Within a chapter folder you'll find begin and end versions of the changed files only. If you want to start a video without working through those that came just before it, you can use the files in the begin folder. The folder structure within the begin folder replicates the path where the file needs to be placed in one of the servers. The easiest approach is to simply copy the folder for the server name to the clipboard and then paste it into the servers folder and select the option to merge files. So for instance here I have files from the resources folder that are changing, so I can right-click on a Mac and click Copy resources and then over in the servers folder I can just right-click servers and click Paste Item and then I get a prompt saying that this folder already exists and asking me if I want to merge, and that's exactly what I want to do. The start files folder contains those files in the correct subdirectory, so I can just click Merge and the start files will replace the files with the same name that I had in that particular server setting me up to start this particular video.
- Working with browser security features
- Configuring servers for testing
- Defining an origin
- Cross-site scripting attacks
- Cross-site request forgery attacks
- Working with a received message
- Specifying the allowed message sender origin
- Sharing cookies across subdomains
- Restricting the path of a cookie