forked from auth0/nextjs-auth0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (28 loc) · 960 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const express = require('express');
const next = require('next');
const oidc = require('../scripts/oidc-provider');
const port = +(process.env.PORT || 3000);
const app = next({ dev: true, hostname: 'localhost', port });
const handle = app.getRequestHandler();
process.env.AUTH0_BASE_URL = 'http://localhost:3000';
process.env.AUTH0_SECRET = 'testing123';
process.env.AUTH0_ISSUER_BASE_URL = `http://localhost:${port}/oidc/`;
process.env.AUTH0_CLIENT_ID = 'testing';
process.env.AUTH0_CLIENT_SECRET = 'testing';
process.env.AUTH0_SCOPE = 'openid profile email offline_access';
app
.prepare()
.then(() => {
const server = express();
server.use('/oidc', oidc({}).callback());
server.all('*', (req, res) => {
return handle(req, res);
});
server.listen(port, (err) => {
if (err) throw err;
console.log(`> Ready on http://localhost:${port}`);
});
})
.catch((err) => {
console.log('Error:::::', err);
});