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

Cloudflare Pages Deploy a Hono site instructions could now use serveStatic from hono/cloudflare-pages #14550

Closed
kpalmvik opened this issue May 13, 2024 · 3 comments
Assignees
Labels
content:edit Request for content edits documentation Documentation edits product:pages

Comments

@kpalmvik
Copy link

Existing documentation URL(s)

Pages > Framework guides > Deploy a Hono site

What changes are you suggesting?

To serve static files using Hono, the following instructions are currently given in the documentation:

To serve static files like CSS, image or JavaScript files, add the following to your src/server.js/ts file:

app.get("/public/*", async (ctx) => {
 return await ctx.env.ASSETS.fetch(ctx.req.raw);
});

This will cause all the files in the public folder within dist to be served in your application.

Since honojs/hono#1273 was added to address honojs/hono#1264 last year it is now possible to instead write:

import { serveStatic } from "hono/cloudflare-pages";

...

app.use("/public/*", serveStatic());

Additionally, this prevents a TypeScript problem that occurs when following the steps in the current documentation:

'ctx.env.ASSETS' is of type 'unknown' ts(18046)

Additional information

No response

@yusukebe
Copy link
Contributor

Hi @kpalmvik

Thank you for the issue and the comment honojs/hono#838 (comment) on the Hono repo.

You are right. We can now use serveStatic() instead of ctx.env.ASSETS.fetch. These (e.g, using esbuild) are old ways, so we have to create the document based on the current starter structure.

I would be able to work on it.

@kpalmvik
Copy link
Author

@yusukebe Would renewing the Cloudflare Pages Hono framework documentation, as discussed in honojs/hono#838, remove the need to even mention serveStatic here?

If so, it probably makes sense to close this issue.

@yusukebe
Copy link
Contributor

Would renewing the Cloudflare Pages Hono framework documentation, as discussed in honojs/hono#838, remove the need to even mention serveStatic here?

Yes! We can remove it.

If so, it probably makes sense to close this issue.

Closing this issue is okay. Shall we keep to discuss it on honojs/hono#838?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:edit Request for content edits documentation Documentation edits product:pages
Projects
None yet
Development

No branches or pull requests

6 participants