title: React needs web server? How do the web application server and react communicate?
body: <p>I'm a student who study web development by myself.
  I'm developing a shopping mall site as my personal project and I've got some elemental questions when I tried to make a login page.</p>
  <p>First of all, I will tell you about the main concepts of my project on the beginning for you to understand my questions more easily.</p>
  <p>My initial concepts and ideas are in below :</p>
  <ul>
  <li><p>Database(MySQL) <br>
  I needed some data to show on the web site. So I decided to use 'Fashion Product Images Dataset' on the Kaggle. Users who sign up will be stored as well.
  I just assumed that there is everything that I need, in order to make the website.</p>
  </li>
  <li><p>Web Application Server(API server)<br />
  I thought this is a kind of bridge which are able to make the javaScript on the browser to get some resources, a sort of product images and prices, when the page is loaded for the first time or the resources need to be changed by users or codes.</p>
  </li>
  <li><p>Web Server(Built-in the React)<br />
  I made the React application using 'create-react-app', so I don't need to think about the web server actually. The only thing that I have done is building some components which display the UI using react library.</p>
  </li>
  </ul>
  <pre><code>FRONT-END                                      BACK-END
   ----------          ----------------------------------------------------------------
  |  CLIENT  | &lt; --- &gt; |   REACT   | &lt; --- &gt; |  API-SERVER  | &lt; --- &gt; |  DATABASE  |
  |   REACT  |         |(WEB-SERVER)| 
  </code></pre>
  <p>When users request my page, React(The built-in server) reply it.
  Then, the users will get the SPA(client-side).</p>
  <p>The SPA doesn't have any data, it will fetch the data from the API server(Because fetching codes are inserted in the .js files).
  Then, The query inside of the api server will get the data from the database.
  And then, the API server gives the data to the SPA.</p>
  <p>It was quite going well until I start to think about the security. As you can see, when we visit other web sites, they use the https not the http. So I wanted to use the https, because it is really important to protect personal data from bad people. When I consider my idea, but, there wasn't any place to put the code which changes http to https.</p>
  <p>Plus, I understood React is just a library, like reactjs.org said. So I think the reason why I am able to use the built-in web server is because the application is made by 'create-react-app'.</p>
  <p>Finally, here are main questions.
  As I know, the https logic should be in the web server. I mean the server which deal with the client's request.</p>
  <ol>
  <li><p>If what the react is a library is true, do I have to build a web server?
  (I think building a web server by Node.js or other languages is the right way, because a library is just a library..!)</p>
  </li>
  <li><p>If I don't need to build a web server, where should I put the logic?</p>
  </li>
  <li><p>Let's imagine that I am totally ready to use https (I made a web server by Node.js and I got a CA to use TLS), and then, the client and the web server are able to communicate safely. But, all of the code which call the API are written in the .js files.
  And the files are now the client's browser. It means client and the API server doesn't have safe connection, because the API server and web server have different domain or port.</p>
  </li>
  </ol>
  <p>Maybe summary of the question 3:<br />
  3.1. When I searched on google, I understood web application server is to deal with requests that web server can not service. In the SPA, but, the request is from the client. Is this right?</p>
  <p>3.1.1. If the question from the client, how to prove it is safe communication between client and web application server? because web server and web application server have different domain or port!</p>