silverwolf-x's picture
download
raw
1.26 kB
import { createNext } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import { fetchViaHTTP } from 'next-test-utils'
describe('Rewritten API Requests should pass OPTIONS requests to the api function', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'pages/api/some-endpoint.js': `
export default (req, res) => {
res.end("successfully hit some-endpoint!")
}
`,
},
nextConfig: {
rewrites: () =>
Promise.resolve({
beforeFiles: [
// Nextjs by default requires a /api prefix, let's remove that
{
source: '/:path*',
destination: '/api/:path*',
},
],
afterFiles: [],
fallback: [],
}),
},
dependencies: {},
})
})
afterAll(() => next.destroy())
it('should pass OPTIONS requests to the api function', async () => {
const res = await fetchViaHTTP(next.url, '/some-endpoint', null, {
method: 'OPTIONS',
headers: {
Origin: 'http://localhost:3000',
},
})
expect(await res.text()).toContain('successfully hit some-endpoint!')
})
})

Xet Storage Details

Size:
1.26 kB
·
Xet hash:
01859a7a83403fd706f87b0deb589f2c0c5b864c5942b8fcf1c7d9515479d244

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.