Skip to content

Commit

Permalink
docs: improve Cloudflare pages deployment for Nx (#1000)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalenguyen authored Apr 4, 2024
1 parent 1eacbaf commit 155adfc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/docs-app/docs/features/api/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ To create an RSS feed for your site, set the `content-type` to be `text/xml` and
```ts
//server/routes/rss.xml.ts

import { defineEventHandler } from 'h3';
import { defineEventHandler, setHeader } from 'h3';
export default defineEventHandler((event) => {
const feedString = `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
</rss>
`;
event.node.res.setHeader('content-type', 'text/xml');
event.node.res.end(feedString);
setHeader(event, 'content-type', 'text/xml');
return feedString;
});
```

Expand Down Expand Up @@ -83,7 +83,7 @@ Dynamic API routes are defined by using the filename as the route path enclosed
import { defineEventHandler } from 'h3';

export default defineEventHandler(
(event: H3Event) => `Hello ${event.context.params?.['name']}!`
(event) => `Hello ${event.context.params?.['name']}!`
);
```

Expand Down Expand Up @@ -219,4 +219,4 @@ export const load = async ({ event }: PageServerLoad) => {

## More Info

API routes are powered by [Nitro](https://nitro.unjs.io). See the Nitro docs for more examples around building API routes.
API routes are powered by [Nitro](https://nitro.unjs.io/guide/routing) and [h3](https://h3.unjs.io/). See the Nitro and h3 docs for more examples around building API routes.
21 changes: 21 additions & 0 deletions apps/docs-app/docs/features/deployment/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,27 @@ To connect your repository and deploy automatically to Cloudflare:

The application deploys to Cloudflare's network on each push to the repository.

:::note

For Nx workspaces, the build output is be under the app name, so you can update the client output directory and server output directory to `./dist` and `./dist/_worker.js` instead.

```
output: {
dir: './dist',
serverDir: './dist/_worker.js',
},
```

After that, enter `YOUR_APP_NAME/dist` as the `Build output directory`.

To test the build locally, run the following command:

```
BUILD_PRESET=cloudflare-pages npx nx build YOUR_APP_NAME
```

:::

### Running the application locally using Wrangler

You can also preview the application running on Cloudflare locally:
Expand Down

0 comments on commit 155adfc

Please sign in to comment.