diff --git a/next.config.js b/next.config.js index 82a16b9..6a135a9 100644 --- a/next.config.js +++ b/next.config.js @@ -25,6 +25,14 @@ const nextConfig = { }, ]; }, + async rewrites() { + return [ + { + source: '/api/badge/:login.svg', + destination: '/badge/:login.svg', + }, + ]; + }, images: { remotePatterns: [ { protocol: 'https', hostname: 'avatars.githubusercontent.com' }, diff --git a/tests/next-config.test.js b/tests/next-config.test.js new file mode 100644 index 0000000..7220201 --- /dev/null +++ b/tests/next-config.test.js @@ -0,0 +1,14 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import nextConfig from '../next.config.js'; + +test('rewrites documented badge API path to badge route', async () => { + const rewrites = await nextConfig.rewrites(); + + assert.deepEqual(rewrites, [ + { + source: '/api/badge/:login.svg', + destination: '/badge/:login.svg', + }, + ]); +});