surrealdb / surrealdb.js

SurrealDB SDK for JavaScript
https://surrealdb.com
Apache License 2.0
272 stars 45 forks source link

[BUG]: Path is ignored in the Connenction URL #217

Closed N0tExisting closed 3 months ago

N0tExisting commented 4 months ago

Describe the bug

When giving a custom path into the connect() method it is ignored.

This is anoying because of my dev setup:

import { defineConfig } from 'vite';

export default defineConfig({
    server: {
        proxy: {
            '/db': 'http://localhost:8000/',
        },
    },
});

Steps to reproduce

import Surreal from 'surrealdb.js';

const db = new Surreal();

const url = new URL(location.href);
url.pathname = '/db/rpc';
url.protocol = url.protocol === 'http' ? 'ws' : 'wss';

await db.connect(url.href, p);

results in:

SurrealSocket.ts:56  WebSocket connection to 'wss://localhost:3000/rpc' failed: 
open @ SurrealSocket.ts:56

Expected behaviour

Connecting to the database should respect the path in the URL.

SurrealDB version

unrelated

SurrealDB.js version

0.11.0

Contact Details

No response

Is there an existing issue for this?

Code of Conduct

kearfy commented 3 months ago

Hey @N0tExisting, the v1.0.0-beta.x release(s) solve this issue 😃