Error [LibsqlError]: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only

I am getting this error when my project have middleware. Error goes away when deleting middleware.ts
LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls
LibsqlError: URL_SCHEME_NOT_SUPPORTED: The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, got "file:". For more information, please read https://github.com/libsql/libsql-client-ts#supported-urls
I am guessing it is because of DATABASE_URL="file:./db.sqlite"
3 Replies
Rivenris
Rivenris3w ago
Do you import the client in the middleware directly or indirectly? For some reason the app thinks you are in non-server mode when creating the client. I've had similar thing, but I was actually importing indirectly client in the client component. For better reference you'd need to share bit more on your setup: how project was created, what's the config, how libsql is imported etc. If you have link to the repo that's even better. Otherwise it's a bit hard to judge what might be wrong.
Rivenris
Rivenris3w ago
Take a look here for reference: https://github.com/tursodatabase/libsql-client-ts/blob/main/packages/libsql-client/package.json The web import is pretty much no-go when it comes to file: scheme. So i'd look for a reason that import is referring to web-only client. If you wanna use local files, the import needs to be from node environment.
GitHub
libsql-client-ts/packages/libsql-client/package.json at main · turs...
TypeScript/JavaScript client API for libSQL. Contribute to tursodatabase/libsql-client-ts development by creating an account on GitHub.
ejoo
ejooOP3w ago
it's a newly created t3 app. all the database setup is default. I have only changed the schema and added a middleware.

Did you find this page helpful?