-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Astro DB - when using --remote flag I get "Invalid URL" #10511
Comments
I've managed to replicate the issue in my development environment, and I've identified a workaround that might provide a temporary solution until the root cause is addressed. It appears that the problem lies in the runtime handling of environment variables, specifically when retrieving credentials using the getRemoteDatabaseUrl() function. Although environment variables set at build time seem to work fine, runtime variables are causing issues. To circumvent this, I've made a temporary adjustment in the createRemoteDatabaseClient function to hardcode my credentials. This ensures that the function operates correctly in my local setup. However, this is not a sustainable solution for production environments. The issue seems to stem from discrepancies in how environment variables are handled between build time and runtime. For instance, while the command npx astro db shell --query 'select "*" from Courses' --remote works as expected, npx astro db execute db/seed.ts --remote fails due to the same problem. In @astrojs/db/dist/core/utils.js, I've observed that the getRemoteDatabaseUrl() function is where the issue originates, particularly in fetching environment variables. I've included a console.log statement to track the ASTRO_STUDIO_APP_TOKEN variable. In terms of code, I've made modifications in one file: In @astrojs/db/dist/runtime/db-client.js, I've made changes to ensure that the getRemoteDatabaseUrl() function fetches the correct environment variables. Additionally, I've modified the createRemoteDatabaseClient function to accept hardcoded credentials temporarily.
While this workaround helps me locally, it's crucial to address the underlying problem with runtime environment variables. I'm willing to contribute a pull request to implement a more robust solution if needed. Looking forward to hearing your thoughts on this and finding a permanent fix. Best regards, |
Is there a way to replicate the hardcoded functionality I've implemented in my local development environment for production? I'm nearing completion on an MVP for a client project, and switching to another database provider like Turso would be quite inconvenient. I've found Astro DB integration incredibly seamless and would prefer to stick with it if possible. |
Should be fixed by #10520 in |
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When I run "astro dev --remote", I get the following error:
22:06:14 [ERROR] Invalid URL
Stack trace:
at /Users/thomasledoux/Documents/website-thomas-astro/node_modules/@astrojs/db/dist/runtime/db-client.js:31:15
[...] See full stack trace in the browser, or rerun with --verbose.
This seems to be coming from
createRemoteDatabaseClient()
where theremoteDbURL
that's passed to it is not valid apparently.What's the expected result?
Connecting to the remote Astro DB
Link to Minimal Reproducible Example
https://github.com/thomasledoux1/website-thomas-astro
Participation
The text was updated successfully, but these errors were encountered: