Commit a51d1e7
committed
fix: fetch org packages via existing server route
Org packages are fetched from the npm registry api (`/-/org/{org}/package`) in two places:
1. Server route `/api/registry/org/[org]/packages.get.ts`:
- calls `$fetch('https://registry.npmjs.org/-/org/{org}/package')`
2. Client composable `useOrgPackages()`: calls `$npmRegistry('/-/org/{org}/package')`
The composable bypasses the server route, duplicating the registry call, org name encoding, and
error handling, and bypassing the important server-side caching. But most importantly, calls to the
registry from the client fail with a CORS error, since the registry doesn't allow cross-origin
requests from browsers.1 parent 188e887 commit a51d1e7
File tree
2 files changed
+11
-8
lines changed- app/composables/npm
- server/api/registry/org/[org]
2 files changed
+11
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | | - | |
| 95 | + | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
| 1 | + | |
| 2 | + | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
41 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| |||
0 commit comments