Cloudflare Pages Functions call 404s #2371
Unanswered
callmetwan
asked this question in
Q&A
Replies: 2 comments
-
It just occurred to me that I probably don't need the Functions er, functionality if I'm using Hono to respond to requests this way. I added a route to src/index.tsx app // <----- Adding this worked!
.post("api/auth/login", async (context) => {
return context.json({ message: "Hello" });
});
app.get("*", (context) => {
return context.render(
<html>
<head>
<link href="/static/style.css" rel="stylesheet" />
<title>misterpoppins</title>
</head>
<body>
<div id="root"></div>
</body>
{import.meta.env.PROD ? (
<script type="module" src="/static/client.js"></script>
) : (
<script type="module" src="/src/client/index.tsx"></script>
)}
</html>
);
});
export default app; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @callmetwan Sorry for the confusion! There is a gap between the example, now called Pages Stack, and the starter code. If you use the starter with Vite, I think the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm building a Cloudflare Pages fullstack app (i.e. not SSG). I'm able to get a local dev environment to respond to requests, with the exception of the client calls to Functions -those always 404. I've cobbled this together from the Hono docs and examples repo. I'm sure I'm just doing something wrong, any hints or tips would be very appreciated!
I noticed that the Hono Cloudflare Pages example uses Wrangler but the Hono default project generated with using the Cloudflare Pages option does not. Maybe it is related to that?
Start dev environment:
vite.config.ts - Derived from the Hono Cloudflare Pages documentation
src/index.tsx - Backend "server"
src/client/index.tsx -
functions/api/[[route]].ts
Beta Was this translation helpful? Give feedback.
All reactions