Error validating datasource `db`: the URL must start with the protocol `mongo` - next.js

ERROR PrismaClientInitializationError: Invalid
`prisma.chat.findMany()` invocation:error: Error
validating datasource `db`: the URL must start with the
protocol `mongo`.
--> schema.prisma:10
| 9 | provider = "mongodb"
10 | url = env("DATABASE_URL")
| Validation Error Count: 1
Different type of methods I've tried so far:
Renaming mongodb to mongo in database URL
Removing the quotes in vercel enviroment variables
adding the enviroment variable to vercel.json
All my environment variables are already in my vercel environments for my project
Works perfectly fine in Dev -> Build -> Start in vscode.
How do you deploy on vercel with prisma mongodb URL error?
Ive seen the same error for others but with different db.

You need to define your environment variables in Vercel. Vercel won't have access to your local .env file.

Related

Serverless Stuck Unable to Create Domain

I have a Lambda service that was created with Serverless. I recently upgraded to Serverless 3. (3.22.0 specifically.) I'm also using serverless-offline 8.8.1 and serverless-domain-manager 4.2.3.
It seems to be "stuck" in a state where the domain cannot be deleted or re-created.
After the upgrade, publishing to my prod stage would fail with:
Serverless Domain Manager: Info: api-prod.example.com: Found apiId: pnedwg0m9b
Serverless Domain Manager: Error: api-prod.example.com: ConflictException: Base path already exists for this domain name
Serverless Domain Manager: Error: api-prod.example.com: Error: Error: api-prod.example.com: Unable to create basepath mapping.
...
Error: Error: Unable to setup base domain mappings for api-prod.example.com
The domain settings in serverless.yml look like this:
custom:
customDomain:
domainName: api-${opt:stage, 'dev'}.example.com
basePath: ''
stage: ${self:provider.stage}
createRoute53Record: true
After searching online, I thought the issue might be that the domain was created with an older version of serverless, so I manually deleted it in the Route53 section of the AWS console, then waited overnight. It doesn't appear in the console now.
I tried to re-create it by doing both:
Having createRoute53Record: true in the serverless.yml and running:
SLS_DEBUG=* serverless deploy --verbose --stage prod
This gives the same "unable to setup base domain mapping..." error as before.
... and also manually creating it:
SLS_DEBUG=* serverless create_domain --verbose --stage prod
That just gives the following error, despite the fact that the domain is not visible in the AWS console:
Custom domain api-prod.example.com already exists.
If I try to delete it via serverless, it also throws an error:
SLS_DEBUG=* serverless delete_domain --verbose --stage prod
Serverless Domain Manager: Error: api-prod.example.com: InvalidChangeBatch: [Tried to delete resource record set [name='api-prod.example.com.', type='A'] but it was not found, Tried to delete resource record set [name='api-prod.example.com.', type='AAAA'] but it was not found]
Serverless Domain Manager: Error: api-prod.example.com: Error: Error: Failed to DELETE A Alias for api-prod.example.com
Some other notes:
The "development" stage doesn't result in any errors when deploying. (I created the domain with the create_domain command, but even with createRoute53Record:true, it deploys without error.)
I've tried bumping serverless-domain-manager to 6.1, but that didn't help.
The api-prod.example.com is not present in neither Route53 nor in API Gateway>Custom domain names.
Not sure if it's relevant but this same API was exposed by both api-prod.example.com and api.example.com. I'm not sure how the api.example.com one was created.

In Symfony 5, the command doctrine:database:create outputs an error instead of creating a database for test environment

I'm learning Symfony 5 at Symfony 5: The Fast Track and I'm at the step 17.4 Working with a Test Database.
I can read from the beginning of this section:
... the Symfony CLI automatically exposes the DATABASE_URL
environment variable. When APP_ENV is test, like set when running
PHPUnit, it changes the database name from main to main_test so
that tests have their very own database.
Before being able to run the test, we need to “initialize” the test
database (create the database and migrate it):
$ APP_ENV=test symfony console doctrine:database:create
$ APP_ENV=test symfony console doctrine:migrations:migrate -n
My database name is guestbook, running under MySql & Apache, as specified in the .env file:
DATABASE_URL="mysql://root:#127.0.0.1:3306/guestbook?serverVersion=mariadb-10.4.19"
So, while I was expecting a database named guestbook_test to be created when I execute the command symfony console doctrine:database:create, it outputs the following error:
Could not create database `guestbook` for connection named default
An exception occurred while executing 'CREATE DATABASE `guestbook`':
SQLSTATE[HY000]: General error: 1007 Can't create database 'guestbook'; database exists
exit status 1
To make sure the environment is "test", I, first, tried these two ways:
In the .env file: APP_ENV=test
In the .env.local file: APP_ENV=test
But, I got the same error.
When I displayed the content of environment variable APP_ENV from a controller, using return new Response("APP_ENV = '" . getenv('APP_ENV') . "'");, it displays a null value: APP_ENV=''.
So, I assigned the value 'test' to APP_ENV in Real environment variables (for me, that was Windows/Paramaters/environment variables...etc). This once, the controller displays APP_ENV='test', but I get always the same error, when I execute the Doctrine command: symfony console doctrine:database:create
I don't know what I'm missing !! Please, any help?
UPDATE ON: 07 June 2021 22:05
I, even tried assigning the value test to APP_ENV in php.ini; but, when I displayed this env var using: symfony console debug:container --env-var=APP_ENV, I got:
Symfony Container Environment Variables
=======================================
// Displaying detailed environment variable usage matching APP_ENV
None of the environment variables match this name.
It's, little bit, strange since I have this env var assigned every where (in .env file, .env.local, php.ini and in a real env vars) and this command says there is no env var called APP_ENV !
What helped in my case:
create .env.local file
copy the DATABASE_URL variable with db name suffixed with _test
I also had to change db user to root, as my app db user didn't have permissions to create databases,

Symfony console output creates extra unwanted characters

i got this weird error, where every output in the console with symfony creates some extra characters. The following is the output after a basic symfony in the console.
$ symfony
←[32mSymfony CLI←[39m version ←[33mv4.22.0←[39m (c) 2017-2021 Symfony SAS
Symfony CLI helps developers manage projects, from local code to remote infrastructure
These are common commands used in various situations:
←[33mWork on a project locally←[39m
←[32mnew←[39m Create a new Symfony project
←[32mserve←[39m Run a local web server
←[32mserver:stop←[39m Stop the local web server
←[32msecurity:check←[39m Check security issues in project dependencies
←[32mcomposer←[39m Runs Composer without memory limit
←[32mconsole←[39m Runs the Symfony Console (bin/console) for current project
←[32mphp, pecl, pear, php-fpm, php-cgi, php-config, phpdbg, phpize←[39m Runs the named binary using the configured PHP version
←[33mManage a project on Cloud←[39m
←[32mlogin←[39m Log in with your SymfonyConnect account
←[32minit←[39m Initialize a new project using templates
←[32mlink←[39m Link current git repository to a SymfonyCloud project
←[32mprojects←[39m List active projects
←[32menvs←[39m List environments
←[32menv:create←[39m Create an environment
←[32mtunnel:open←[39m Open SSH tunnels to the app's services
←[32mssh←[39m Open an SSH connection to the app container
←[32mdeploy←[39m Deploy an environment
←[32mdomains←[39m List domains
←[32mvars←[39m List variables
←[32muser:add←[39m Add a user to the project
Show all commands with ←[32msymfony.exe help←[39m,
Get help for a specific command with ←[32msymfony.exe help COMMAND←[39m.
As you can see, I get this ←[33m here and there. Any help is gratefully accepted. Please let me know if you need any additional information from me.
$ bin/console --version
Symfony 5.2.1 (env: dev, debug: true)

Auth0 and Next.js deployed to Vercel: Location header error

I started with this sample repo: https://github.com/vercel/next.js/tree/canary/examples/auth0
My current repo: https://github.com/rebeccapeltz/next-auth-app-1
Login/Logout work fine locally. When I deploy to Vercel and logout I get this message in the browser:
Invalid character in header content ["Location"]
I've double checked the Auth0 env variables and they seem correct. Login works fine on Vercel. Can't figure out how to troubleshoot the header Location value that is causing the problem.
Nothing much going on yet and easy to reproduce: https://next-auth-app-1.now.sh/
Solved this by removing all env variables added to the Vercel online application settings. Then added the secrets using the now CLI now secrets add and deployed the app by setting up other env variables in now.json and using now --prod. Working OK now. For further external env secrets and references, I'm wondering if t's better to add them via now.json or to use the online settings GUI. One thing that wasn't clear is that when you add variables with now add secrets you need to prefix the value in the now.json with #. Kind of like accessing bash env variables with $. So after adding secrets my now.json looks like this
{
"build": {
"env": {
"AUTH0_DOMAIN": "<name of auth0 domain>",
"AUTH0_CLIENT_ID": "<what you get from auth0>",
"AUTH0_CLIENT_SECRET": "#auth0_client_secret",
"REDIRECT_URI": "<name of vercel app or domain name>/api/callback",
"POST_LOGOUT_REDIRECT_URI": "<name of vercel app>/",
"SESSION_COOKIE_SECRET": "#session_cookie_secret"
}
}
}
Should you add all env using secrets add and then just reference by name in the now.json? not sure.

Deploy on Meteor galaxy server with bitbucket and deployment token as variable

Hello I want to use the automatic deploymen on bitbucket to the galaxy server with a deployment token.
For this reason I am creating a deployment token that is comitted in the repository.
https://galaxy-guide.meteor.com/deploy-guide.html#deployment-token
To strenghten the security I would like to use Repository variables in bitbucket pipelines:
https://confluence.atlassian.com/bitbucket/environment-variables-794502608.html
And to store the deployment token of meteor in the variables instead in file.
For the deployment we use in the command:
METEOR_SESSION_FILE=deployment_token.json
And my question is - Is there any way so that I use some variable(string) where the token is used like
METEOR_SESSION_DEPLOYMENT_TOKEN=$METEOR_TOKEN
instead to call it from a file?
Some research, after having the same problem, brought me to this article, which simply solves the problem that you can't feed meteor just the json in an env var in the following simple way:
By adding the json file content as an env var and then echoes it out into a file on deploy.
echo $METEOR_TOKEN_FILE > deploy_token.json
METEOR_SESSION_FILE=deploy_token.json
Thanks to this article I figured it out.
Save json settings as env variable and then in deployment procesS:
echo $DEPLOY_SESSION_FILE > deployment_token.json
METEOR_SESSION_FILE=deployment_token.json DEPLOY_HOSTNAME=galaxy.meteor.com meteor deploy --allow-superuser myApp-staging.meteorapp.com --settings config/staging/settings.json --owner username

Resources