Describe the issue
I have a very basic setup for an Express.js application and am trying to add Auth.js to it. When I do so the API starts up however when loading any path beyond /api/auth it causes the below stack trace and no logs in the console. Only other indication of an issue is it redirects to /api/auth/error?error=Configuration
[auth][error] TypeError: (0 , import_preact_render_to_string.renderToString) is not a function
api:dev: at send (/Users/josh/projects/saas-starter-kit/node_modules/@auth/core/lib/pages/index.js:13:350)
api:dev: at Object.error (/Users/josh/projects/saas-starter-kit/node_modules/@auth/core/lib/pages/index.js:119:20)
api:dev: at AuthInternal (/Users/josh/projects/saas-starter-kit/node_modules/@auth/core/lib/index.js:31:31)
api:dev: at Auth (/Users/josh/projects/saas-starter-kit/node_modules/@auth/core/index.js:109:34)
api:dev: at (/Users/josh/projects/saas-starter-kit/node_modules/@auth/express/index.js:141:45)
How to reproduce
tsconfig.json
{
“compilerOptions”: {
“target”: “es2016”,
“module”: “commonjs”,
“outDir”: “./dist”,
“esModuleInterop”: true,
“forceConsistentCasingInFileNames”: true,
“strict”: true,
“skipLibCheck”: true
}
}
index.ts
import { logger } from ‘@repo/logger’
import ‘dotenv/config’
import { createServer } from ‘./server’
const port = process.env.PORT || 3001
const server = createServer()
server.listen(port, async() => {
logger.info(api server is starting: Date: ${new Date()}
)
})
server.ts
import express, { type Express } from ‘express’
import morgan from ‘morgan’
import { ExpressAuth } from “@auth/express”
import GitHub from “@auth/express/providers/github”
export const createServer = (): Express => {
const app = express()
app
.use(express.urlencoded({ extended: true }))
.use(express.json())
.set("trust proxy", true)
.use("/api/auth/*", ExpressAuth({
debug: true,
trustHost: true,
providers: [
GitHub
],
}))
.get('/status', (_, res) => {
return res.json({ ok: true })
})
return app
}
.env.local
AUTH_SECRET=””
AUTH_GITHUB_ID=””
AUTH_GITHUB_SECRET=””
AUTH_URL=”http://localhost:3001/api/auth”
command to start up
dotenvx run –env-file ./.env.local — nodemon –exec “node -r esbuild-register ./src/index.ts” -e .ts
Expected behavior
I would have expected the signin page to load something rather than a server console error message.