-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Issue Type
Other
Location (if applicable)
prisma/seed.ts
What's wrong?
Reproduction
Using the current implementation in prisma/seed.ts:
const cities = await fetchData('cities');
This resolves internally to the following endpoint:
https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/json/cities.json
The request now returns:
404: Not Found
Root Cause
The repository no longer contains the file:
json/cities.json
Instead, only the compressed version is available:
json/cities.json.gz
Since the existing seeder logic expects an uncompressed .json file and does not handle gzip decompression, the request fails and results in a 404 error.
What should it be?
Update prisma/seed.ts
Modify the seeder to:
Fetch .json.gz
Decompress using zlib
Parse JSON
Example fix:
import { gunzipSync } from 'zlib';
async function fetchGzipJson(endpoint: string) {
const response = await fetch(${API_BASE}${endpoint}.json.gz);
const buffer = Buffer.from(await response.arrayBuffer());
const decompressed = gunzipSync(buffer);
return JSON.parse(decompressed.toString('utf-8'));
}
Then replace:
await fetchData('cities')
with:
await fetchGzipJson('cities')
Source (optional)
No response