next.js/test/e2e/app-dir/app-middleware-proxy/app-middleware-proxy-without-pages-dir.test.ts
app-middleware-proxy-without-pages-dir.test.ts30 lines721 B
/* eslint-env jest */
import path from 'path'
import { nextTestSetup, FileRef } from 'e2e-utils'

describe('app dir - proxy without pages dir', () => {
  const { next } = nextTestSetup({
    files: {
      app: new FileRef(path.join(__dirname, 'app')),
      'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
      'proxy.js': `
      import { NextResponse } from 'next/server'

      export async function proxy(request) {
        return new NextResponse('redirected')
      }

      export const config = {
        matcher: '/headers'
      }
    `,
    },
  })

  it('Updates headers', async () => {
    const html = await next.render('/headers')

    expect(html).toContain('redirected')
  })
})
Quest for Codev2.0.0
/
SIGN IN