Skip to content

Commit 58c2bd8

Browse files
Update readme (#7)
* Update readme for setup * Add console.error in callback * Add more links * Clone with SSH * Casing fix * Update src/app/callback/route.ts Co-authored-by: Andy Hook <[email protected]> * Log same message in res * Rework to numbered steps * Remove extra language --------- Co-authored-by: Andy Hook <[email protected]>
1 parent 1f1d91d commit 58c2bd8

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

README.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,35 @@
22

33
An example application demonstrating how to authenticate users with AuthKit and the WorkOS Node SDK.
44

5-
## Project setup
5+
> Refer to the [User Management](https://workos.com/docs/user-management) documentation for reference.
66
7-
To get started, clone the repo:
7+
## Prerequisites
88

9-
```bash
10-
git clone https://github.com/workos/next-authkit-example.git
11-
```
9+
You will need a [WorkOS account](https://dashboard.workos.com/signup).
1210

13-
Navigate to the cloned repo and install the dependencies:
11+
## Running the example
1412

15-
```bash
16-
npm install
17-
```
13+
1. In the [WorkOS dashboard](https://dashboard.workos.com), head to the Redirects tab and create a [sign-in callback redirect](https://workos.com/docs/user-management/1-configure-your-project/configure-a-redirect-uri) for `http://localhost:3000/callback`.
1814

19-
## Getting started with WorkOS
15+
2. After creating the redirect URI, navigate to the API keys tab and copy the _Client ID_ and the _Secret Key_. Rename the `.env.local.example` file to `.env.local` and supply your Client ID and API key as environment variables.
2016

21-
Sign up for a [WorkOS account](https://dashboard.workos.com/signup), log in, navigate to the API keys tab and copy the _Client ID_ and the _Secret Key_.
17+
3. Additionally, [create a signing secret](https://workos.com/docs/user-management/3-handle-the-user-session/create-a-signing-secret) by running the below command. Copy the output into the environment variable `JWT_SECRET_KEY`.
2218

23-
Rename the `.env.local.example` file to `.env.local` and supply your Client ID and API key.
19+
```bash
20+
node -e "console.log(require('crypto').randomBytes(64).toString('base64'));"
21+
```
2422

25-
Finally, start the development environment and navigate to http://localhost:3000.
23+
4. Verify your `.env.local` file has the following variables filled.
2624

27-
```bash
28-
npm run dev
29-
```
25+
```bash
26+
WORKOS_CLIENT_ID=<YOUR_CLIENT_ID>
27+
WORKOS_API_KEY=<YOUR_API_SECRET_KEY>
28+
WORKOS_REDIRECT_URI=http://localhost:3000/callback
29+
JWT_SECRET_KEY=<YOUR_JWT_SECRET_KEY>
30+
```
31+
32+
5. Run the following command and navigate to [http://localhost:3000](http://localhost:3000).
33+
34+
```bash
35+
npm run dev
36+
```

src/app/callback/route.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ export async function GET(request: NextRequest) {
4343

4444
return response;
4545
} catch (error) {
46-
return NextResponse.json(error);
46+
const errorRes = {
47+
error: error instanceof Error ? error.message : String(error),
48+
};
49+
console.error(errorRes);
50+
return NextResponse.json(errorRes);
4751
}
4852
}
4953

0 commit comments

Comments
 (0)