Skip to content

Commit

Permalink
fix: node 12 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Nov 5, 2021
1 parent f169c9c commit f15a35b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/nextjs/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import supertest from 'supertest'
import parse from 'set-cookie-parser'
import http from 'http'
import { Application } from 'express-serve-static-core'
import DoneCallback = jest.DoneCallback

interface AppResult {
app: Application
Expand Down Expand Up @@ -32,9 +33,6 @@ describe('NextJS handler', () => {
let app: AppResult

afterEach((done) => {
if (!app) {
done()
}
app.server.close(done)
})

Expand Down Expand Up @@ -237,7 +235,7 @@ describe('NextJS handler', () => {

expect(response.headers['location']).toContain('/api/.ory/ui/login')
const loc = response.headers['location']
.replaceAll('/api/.ory/', '')
.replace('/api/.ory/', '')
.split('/')
.map((p: string) => `paths=${p}`)
.join('&')
Expand Down
6 changes: 5 additions & 1 deletion src/nextjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ export function createApiHandler(options: CreateApiHandlerOptions) {
res.status(code)
if (buf.length > 0) {
if (isText(null, buf)) {
res.send(buf.toString('utf-8').replaceAll(baseUrl, '/api/.ory'))
res.send(
buf
.toString('utf-8')
.replace(new RegExp(baseUrl, 'g'), '/api/.ory')
)
} else {
res.write(buf)
}
Expand Down

0 comments on commit f15a35b

Please sign in to comment.