Use supabase ipv4

This commit is contained in:
MartinBraquet
2025-09-01 14:14:41 +02:00
parent 720fa70d60
commit 2c5339aa92
2 changed files with 15 additions and 20 deletions

View File

@@ -6,11 +6,6 @@
set -e
if [ -z "$1" ]; then
echo "Usage: the first argument should be 'dev' or 'prod'"
exit 1
fi
SERVICE_NAME="api"
SERVICE_GROUP="${SERVICE_NAME}-group"
ZONE="us-west1-c"
@@ -27,11 +22,16 @@ case $ENV in
esac
echo "Looking for API instance on ${GCLOUD_PROJECT} to talk to..."
INSTANCE_ID=$(gcloud compute instance-groups list-instances ${SERVICE_GROUP} --format="value(NAME)" --zone=${ZONE} --project=${GCLOUD_PROJECT})
INSTANCE_ID=$(gcloud compute instances list \
--filter="zone:(us-west1-c)" \
--sort-by="~creationTimestamp" \
--format="value(name)" \
--limit=1)
echo "Forwarding debugging port 9229 to ${INSTANCE_ID}. Open chrome://inspect in Chrome to connect."
echo gcloud compute ssh ${INSTANCE_ID} --project=${GCLOUD_PROJECT} --zone=${ZONE}
gcloud compute ssh ${INSTANCE_ID} \
--project=${GCLOUD_PROJECT} \
--zone=${ZONE} \
-- \
-NL 9229:localhost:9229
# -- \
# -NL 9229:localhost:9229

View File

@@ -52,25 +52,20 @@ const newClient = (
) => {
const { instanceId, password, ...settings } = props
console.log({
const config = {
host: 'db.ltzepxnhhnrnvovqblfr.supabase.co',
port: 5432,
user: `postgres`,
password: password,
database: 'postgres',
ssl: { rejectUnauthorized: false },
family: 4, // <- forces IPv4
...settings,
})
}
return pgp({
host: 'db.ltzepxnhhnrnvovqblfr.supabase.co',
port: 5432,
user: `postgres`,
password: password,
database: 'postgres',
ssl: { rejectUnauthorized: false },
...settings,
})
console.log(config)
return pgp(config)
}
// Use one connection to avoid WARNING: Creating a duplicate database object for the same connection.
@@ -89,7 +84,7 @@ export function createSupabaseDirectClient(
password = password ?? process.env.SUPABASE_DB_PASSWORD
if (!password) {
throw new Error(
"Can't connect to Supabase; no process.env.SUPABASE_PASSWORD."
"Can't connect to Supabase; no process.env.SUPABASE_DB_PASSWORD."
)
}
const client = newClient({