change: everything
This commit is contained in:
parent
1e09c02cb9
commit
a49c5d8bcc
15 changed files with 1107 additions and 229 deletions
16
app/routes/api.posts.$postId.ts
Normal file
16
app/routes/api.posts.$postId.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { type LoaderFunctionArgs } from "react-router";
|
||||
|
||||
export async function loader({ params, context }: LoaderFunctionArgs) {
|
||||
const { postId } = params;
|
||||
|
||||
// 'context.cloudflare.env' contains your bindings
|
||||
const { API } = context.cloudflare.env;
|
||||
|
||||
// Use the Service Binding to talk to the backend
|
||||
// This is much faster than a standard fetch over the internet
|
||||
const response = await API.fetch(
|
||||
`http://internal/posts/${postId}/view`
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue