Make Supabase postgres urls more resilient (#257)

* Bump deps

* Remove redundant postgres ssl query param

* Tweak postgres code

* Refactor postgres url formatting

* Change postgres url imports
This commit is contained in:
Sam Becker 2025-05-22 01:07:04 -05:00 committed by GitHub
parent 1e55949d11
commit eabdbf1329
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 1007 additions and 1216 deletions

View File

@ -49,6 +49,7 @@
"Reala",
"skippable",
"sonner",
"sslmode",
"Streamable",
"Supabase",
"thephotoblog",

View File

@ -10,35 +10,35 @@
},
"dependencies": {
"@ai-sdk/openai": "^1.3.22",
"@aws-sdk/client-s3": "3.806.0",
"@aws-sdk/s3-request-presigner": "3.806.0",
"@radix-ui/react-dialog": "^1.1.13",
"@radix-ui/react-dropdown-menu": "^2.1.14",
"@radix-ui/react-tooltip": "^1.2.6",
"@radix-ui/react-visually-hidden": "^1.2.2",
"@aws-sdk/client-s3": "3.815.0",
"@aws-sdk/s3-request-presigner": "3.815.0",
"@radix-ui/react-dialog": "^1.1.14",
"@radix-ui/react-dropdown-menu": "^2.1.15",
"@radix-ui/react-tooltip": "^1.2.7",
"@radix-ui/react-visually-hidden": "^1.2.3",
"@upstash/ratelimit": "^2.0.5",
"@upstash/redis": "^1.34.9",
"@vercel/analytics": "^1.5.0",
"@vercel/blob": "^1.0.1",
"@vercel/blob": "^1.0.2",
"@vercel/speed-insights": "^1.2.0",
"ai": "^4.3.15",
"ai": "^4.3.16",
"camelcase-keys": "^9.1.3",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"date-fns": "^4.1.0",
"date-fns-tz": "^3.2.0",
"fast-deep-equal": "^3.1.3",
"framer-motion": "^12.10.5",
"framer-motion": "^12.12.1",
"nanoid": "^5.1.5",
"next": "15.3.2",
"next-auth": "5.0.0-beta.27",
"next-themes": "^0.4.6",
"pg": "^8.15.6",
"pg": "^8.16.0",
"react": "19.1.0",
"react-dom": "19.1.0",
"react-icons": "^5.5.0",
"sanitize-html": "^2.16.0",
"sharp": "^0.34.1",
"sanitize-html": "^2.17.0",
"sharp": "^0.34.2",
"sonner": "^2.0.3",
"swr": "^2.3.3",
"ts-exif-parser": "^0.2.2",
@ -51,24 +51,24 @@
"@next/eslint-plugin-next": "^15.3.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.10",
"@tailwindcss/postcss": "^4.1.6",
"@tailwindcss/postcss": "^4.1.7",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.15.17",
"@types/pg": "^8.15.1",
"@types/react": "19.1.3",
"@types/react-dom": "19.1.3",
"@types/node": "^22.15.21",
"@types/pg": "^8.15.2",
"@types/react": "19.1.5",
"@types/react-dom": "19.1.5",
"@types/sanitize-html": "^2.16.0",
"cross-fetch": "^4.1.0",
"eslint": "9.26.0",
"eslint": "9.27.0",
"eslint-config-next": "15.3.2",
"eslint-plugin-react-hooks": "^5.2.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"postcss": "8.5.3",
"tailwindcss": "4.1.6",
"tailwindcss": "4.1.7",
"ts-node": "^10.9.2",
"typescript": "5.8.3"
},

2166
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,10 @@ import {
} from '@/photo/ai';
import { getOrderedCategoriesFromString } from '@/category';
import type { StorageType } from '@/platforms/storage';
import { makeUrlAbsolute, shortenUrl } from '@/utility/url';
import {
makeUrlAbsolute,
shortenUrl,
} from '@/utility/url';
// HARD-CODED GLOBAL CONFIGURATION

View File

@ -1,8 +1,9 @@
import { POSTGRES_SSL_ENABLED } from '@/app/config';
import { Pool, QueryResult, QueryResultRow } from 'pg';
import { removeParamsFromUrl } from '@/utility/url';
import { Pool, QueryResult, QueryResultRow } from 'pg';
const pool = new Pool({
connectionString: process.env.POSTGRES_URL,
connectionString: removeParamsFromUrl(process.env.POSTGRES_URL, ['sslmode']),
...POSTGRES_SSL_ENABLED && { ssl: true },
});

View File

@ -18,6 +18,14 @@ export const makeUrlAbsolute = (url?: string) => url !== undefined
.replace(/\/$/, '')
: undefined;
export const removeParamsFromUrl = (urlString = '', params: string[]) => {
const url = new URL(urlString);
for (const param of params) {
url.searchParams.delete(param);
}
return url.toString();
};
export const downloadFileFromBrowser = async (
url: string,
fileName: string,