https://hyperdrive-test-dbt.pages.dev/api/test-hyperdrive
error: {"success":false,"error":"Uncaught TypeError: Failed to establish the WebSocket connection: expected server to reply with HTTP status code 101 (switching protocols), but received 530 instead."}
I can connect to the database normally, but I can't connect via Hyperdrive. How should I fix this?
code:
import { Client } from "pg";
export default {
async fetch(request, env, ctx) {
// Hyperdrive provides a unique generated connection string to connect to
// your database via Hyperdrive that can be used with your existing tools
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
try {
// Sample SQL query
const result = await client.query("SELECT * FROM pg_tables");
return Response.json({result: result.rows});
} catch (e) {
return Response.json({ error: e instanceof Error ? e.message : e }, { status: 500 });
}
},
}
https://hyperdrive-test-dbt.pages.dev/api/test-hyperdrive
error: {"success":false,"error":"Uncaught TypeError: Failed to establish the WebSocket connection: expected server to reply with HTTP status code 101 (switching protocols), but received 530 instead."}
I can connect to the database normally, but I can't connect via Hyperdrive. How should I fix this?
code:
import { Client } from "pg";
export default {
async fetch(request, env, ctx) {
// Hyperdrive provides a unique generated connection string to connect to
// your database via Hyperdrive that can be used with your existing tools
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
},
}