From the course: Learning Apollo

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Connect Apollo server to React client

Connect Apollo server to React client

From the course: Learning Apollo

Start my 1-month free trial

Connect Apollo server to React client

- [Tutor] Now that we have an Apollo GraphQL server running, it's time to connect our React application to our Apollo server, leveraging the ApolloClient, let's get to it. So the first thing I want you to do is go back into your terminal, so you do Control Grave or you go to View, Integrated Terminal and let's stop the server for a second, Control C, like so and we'll need to install CORS, npm install and save it to our regular dependencies. So the next thing we need to do is make a few changes here, so for example, we first need to import cors from cors, like so and then here just below the const express and let's move that like so, do server.use and for any issues with cross-origins and this is basically making sure that we're not going to have any issues with having cross-origins issues in between servers and things like that, so that helps with that particular issue, so the origin and we're solving that issue by naming what is the server, that we're going to call the server from…

Contents