Skip to content

Commit c9b8b1d

Browse files
authored
Make response empty for API not found errors with extensions (#68)
1 parent bd7d6e9 commit c9b8b1d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Udibo React App
22

3-
[![release](https://img.shields.io/badge/release-0.13.0-success)](https://github.com/udibo/react_app/releases/tag/0.13.0)
4-
[![deno doc](https://doc.deno.land/badge.svg)](https://deno.land/x/udibo_react_app@0.13.0)
3+
[![release](https://img.shields.io/badge/release-0.14.0-success)](https://github.com/udibo/react_app/releases/tag/0.14.0)
4+
[![deno doc](https://doc.deno.land/badge.svg)](https://deno.land/x/udibo_react_app@0.14.0)
55
[![CI/CD](https://github.com/udibo/react_app/actions/workflows/main.yml/badge.svg)](https://github.com/udibo/react_app/actions/workflows/main.yml)
66
[![codecov](https://codecov.io/gh/udibo/react_app/branch/main/graph/badge.svg?token=G5XCR01X8E)](https://codecov.io/gh/udibo/react_app)
77
[![license](https://img.shields.io/github/license/udibo/react_app)](https://github.com/udibo/react_app/blob/main/LICENSE)
@@ -31,13 +31,13 @@ Apps are created using [React Router](https://reactrouter.com),
3131

3232
This module has 2 entry points.
3333

34-
- [mod.tsx](https://deno.land/x/udibo_react_app@0.13.0/mod.tsx): For use in code
34+
- [mod.tsx](https://deno.land/x/udibo_react_app@0.14.0/mod.tsx): For use in code
3535
that will be used both on the server and in the browser.
36-
- [server.tsx](https://deno.land/x/udibo_react_app@0.13.0/server.tsx): For use
36+
- [server.tsx](https://deno.land/x/udibo_react_app@0.14.0/server.tsx): For use
3737
in code that will only be used on the server.
3838

3939
You can look at the [examples](#examples) and
40-
[deno docs](https://deno.land/x/udibo_react_app@0.13.0) to learn more about
40+
[deno docs](https://deno.land/x/udibo_react_app@0.14.0) to learn more about
4141
usage.
4242

4343
### Examples

server.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,15 +566,18 @@ export function generateRouter(
566566

567567
const router = new Router();
568568
if (parent?.react && !react) {
569-
router.use(async ({ response }, next) => {
569+
router.use(async ({ request, response }, next) => {
570570
try {
571571
await next();
572572
} catch (cause) {
573573
const error = HttpError.from(cause);
574574
console.error("API error", error);
575575

576576
response.status = error.status;
577-
response.body = HttpError.json(error);
577+
const extname = path.extname(request.url.pathname);
578+
if (error.status !== 404 || extname === "") {
579+
response.body = HttpError.json(error);
580+
}
578581
}
579582
});
580583
}

0 commit comments

Comments
 (0)