Skip to content

Commit

Permalink
feat: updates readme.md file
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoshnirmalya committed Aug 31, 2020
1 parent 0f69bbf commit ab1e206
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEXT_PUBLIC_API_URL=http://localhost:1337/graphql
NEXT_PUBLIC_DATABASE_URL=postgres://strapi:strapi@localhost:5432/strapi
NEXT_PUBLIC_DATABASE_URL=postgres://strapi:strapi@localhost:5432/strapi?synchronize=true
NEXTAUTH_URL=http://localhost:3000
GOOGLE_CLIENT_ID=""
GOOGLE_CLIENT_SECRET=""
4 changes: 3 additions & 1 deletion frontend/lib/with-graphql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const WithGraphQL = ({
const token = session?.jwt?.toString();

const client = new ApolloClient({
uri: process.env.NEXT_PUBLIC_API_URL || "http://localhost:1337/",
uri:
`${process.env.NEXT_PUBLIC_API_URL}/graphql` ||
"http://localhost:1337/graphql",
credentials: "same-origin",
cache: new InMemoryCache(),
headers: {
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const options = {

if (isSignIn) {
const response = await fetch(
`http://localhost:1337/auth/${account.provider}/callback?access_token=${account?.accessToken}`
`${process.env.NEXT_PUBLIC_API_URL}/auth/${account.provider}/callback?access_token=${account?.accessToken}`
);

const data = await response.json();
Expand Down
28 changes: 27 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ cd frontend && yarn install

### 3. **Create a .env file and copy the contents from .env.example (present in frontend directory)**

We might need to run the following command:

```sh
source .env
```

### 4. **Create and copy the Google client credentials**

Create a new [Google OAuth Client](https://console.developers.google.com/apis/credentials/oauthclient) and copy the credentials (Client ID and Client Secret) in your .env file.
Expand All @@ -98,7 +104,7 @@ The above command will start the frontend application on [http://localhost:3000/
### 6. **Go inside the directory of the backend package on another terminal window**

```sh
cd packages/backend
cd backend
```

### 7. **Start docker-compose**
Expand All @@ -109,6 +115,26 @@ docker-compose up

We need to start Docker and then run the above command which will change the current directory to the backend package’s directory and then start the backend package. If everything goes well, it’ll be up and running on [http://localhost:1337/v1/graphql](http://localhost:1337/v1/graphql).

### 8. **Configure Strapi**

a. Allow permissions for all operations on the Feed content-type for Authenticated users.

![Authenticated user role](https://user-images.githubusercontent.com/6391763/91742056-40711100-ebd3-11ea-8430-2e09016901ad.png)

![Allow permissions for all operations on the Feed content-type for Authenticated users](https://user-images.githubusercontent.com/6391763/91742068-449d2e80-ebd3-11ea-9830-df26a3bbfed6.png)

b. Allow permissions for all operations on the Feed content-type for Authenticated users as well.

![Allow permissions for all operations on the Feed content-type for Authenticated users as well](https://user-images.githubusercontent.com/6391763/91742071-45ce5b80-ebd3-11ea-8345-abdbf52c7e41.png)

c. Enable the Google provider.

![Enable the Google provider](https://user-images.githubusercontent.com/6391763/91742074-46ff8880-ebd3-11ea-82c8-5a08e3ecf3de.png)

![Enable informations for the Google provider](https://user-images.githubusercontent.com/6391763/91742078-47981f00-ebd3-11ea-97e4-9cd8c2a27f05.png)

d. Click on the "Done" button and now we can log into our Next.js application using our Google account.

## Deployment

### Frontend application
Expand Down

0 comments on commit ab1e206

Please sign in to comment.