Skip to content

Commit

Permalink
fix: allow v2 functions to serve /favicon.ico (#6145)
Browse files Browse the repository at this point in the history
* fix: allow v2 functions to serve /favicon.ico

* fix: remove favicon handling
  • Loading branch information
Skn0tt authored Nov 10, 2023
1 parent 2547532 commit 9e5f5c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/lib/functions/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,6 @@ const getFunctionsServer = (options) => {
}),
)

app.get('/favicon.ico', function onRequest(_req, res) {
res.status(204).end()
})

app.all(`${functionsPrefix}*`, functionHandler)
app.all(`${buildersPrefix}*`, functionHandler)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default () => new Response(`custom-generated favicon`)

export const config = {
path: '/favicon.ico',
method: 'GET',
}
6 changes: 6 additions & 0 deletions tests/integration/commands/dev/v2-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ describe.runIf(gte(version, '18.13.0'))('v2 api', () => {
expect(await response.text()).toBe(`Catchall Path`)
})

test<FixtureTestContext>('functions can also run on /favicon.ico', async ({ devServer }) => {
const response = await fetch(`http://localhost:${devServer.port}/favicon.ico`)
expect(response.status).toBe(200)
expect(await response.text()).toBe('custom-generated favicon')
})

test<FixtureTestContext>('returns 404 when using the default function URL to access a function with custom routes', async ({
devServer,
}) => {
Expand Down

2 comments on commit 9e5f5c7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

  • Dependency count: 1,395
  • Package size: 404 MB

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

  • Dependency count: 1,395
  • Package size: 404 MB

Please sign in to comment.