Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hono/cloudflare-pages 404 handler doesn't work #966

Closed
Skye-31 opened this issue Mar 8, 2023 · 1 comment
Closed

hono/cloudflare-pages 404 handler doesn't work #966

Skye-31 opened this issue Mar 8, 2023 · 1 comment

Comments

@Skye-31
Copy link

Skye-31 commented Mar 8, 2023

As shown in the snippet below, when using hono's cloudflare pages handler, it doesn't inherit the 404 handler of the original app, so it responds with Hono's generic plaintext 404 (thanks to new Hono().route(...))

export const onRequest = handle(app, '/api');

export const handle: HandleInterface =
<E extends Env>(subApp: Hono<E>, path?: string) =>
({ request, env, waitUntil }) => {
const app = path ? new Hono<E>().route(path, subApp) : subApp
return app.fetch(request, env, { waitUntil, passThroughOnException: () => {} })
}

@yusukebe
Copy link
Member

yusukebe commented Mar 9, 2023

Hi @Skye-31 !

Yes, you are right. app.route() does not inherit the Not Found handler of "subApp". So we were about to deprecate passing the path as the second argument. Instead, we will recommend specifying base path with the basePath method:

const app = new Hono().basePath('/api')

//...

export const onRequest = handle(app)

This feature is not merged #964 , but it will be merged soon! We will write about that in the documentation after releasing.

Thank you for the issue.

@Skye-31 Skye-31 closed this as completed Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants