ionescu77 / encode-bootcamp-lesson06a

Lesson 06 a - first part (Exercises 1 & 2)
0 stars 0 forks source link

Link to vercel #1

Closed ionescu77 closed 2 weeks ago

ionescu77 commented 2 weeks ago

Deploy 2 vercel

npm i -g vercel
vercel link
Vercel CLI 37.1.2
> > No existing credentials found. Please log in:
? Log in to Vercel Continue with Email
? Enter your email address: ion------@gmail.com
We sent an email to ion------@gmail.com. Please follow the steps provided inside it and make sure the security code matches ------------.
> Success! Email authentication complete for ion------@gmail.com
? Set up “~/myProjects/encode-bootcamp-lesson-06a”? yes
? Which scope should contain your project? ion----'s projects
? Link to existing project? no
? What’s your project’s name? encode-bootcamp-lesson-06a
? In which directory is your code located? ./
Local settings detected in vercel.json:
Auto-detected Project Settings (Next.js):
- Build Command: next build
- Development Command: next dev --port $PORT
- Install Command: `yarn install`, `pnpm install`, `npm install`, or `bun install`
- Output Directory: Next.js default
? Want to modify these settings? no
✅  Linked to ion-----s-projects/encode-bootcamp-lesson-06a (created .vercel)
vercel env add OPENAI_API_KEY
Vercel CLI 37.1.2
? What's the value of OPENAI_API_KEY?
blablabla
? Add OPENAI_API_KEY to which Environments (select multiple)?
 ◉ Production
 ◉ Preview
❯◉ Development
✅  Added Environment Variable OPENAI_API_KEY to Project encode-bootcamp-lesson-06a [303ms]

Run the Vercel CLI deploy command in your terminal in the root of your project's folder to deploy your project:

vercel
vercel
Vercel CLI 37.1.2
🔍  Inspect: https://vercel.com/ion---s-projects/encode-bootcamp-lesson-06a/3c6oLpeQru6wiwx295HpvCwN9H5W [2s]
✅  Production: https://encode-bootcamp-lesson-06a-1p333cppg-io-----s-projects.vercel.app [2s]
📝  Deployed to production. Run `vercel --prod` to overwrite later (https://vercel.link/2F).
💡  To change the domain or build command, go to https://vercel.com/i------s-projects/encode-bootcamp-lesson-06a/settings
~/--Projects/encode-bootcamp-lesson-06a master ❯
ionescu77 commented 2 weeks ago

works.

Question

Screenshot 2024-08-28 at 14 27 31
ionescu77 commented 2 weeks ago

Public - Problem

PS I have checked project settings Security and it should've asked for vercel authentication PPS. Even with another setting it has built for production:

vercel --target=preview
Vercel CLI 37.1.2
🔍  Inspect: https://vercel.com/io----s-projects/encode-bootcamp-lesson-06a/Gztp6uddVq455ytKQcuGxdPBDqvc [1s]
✅  Production: https://encode-bootcamp-lesson-06a-gb8wkcv72-ion----s-projects.vercel.app [1s]
📝  Deployed to production. Run `vercel --prod` to overwrite later (https://vercel.link/2F).
💡  To change the domain or build command, go to https://vercel.com/io----s-projects/encode-bootcamp-lesson-06a/settings

When you deploy a project to Vercel using the vercel command, by default, it deploys the code to the Production environment and makes it publicly accessible via a generated Vercel domain (e.g., https://your-project-name.vercel.app). This is the standard behavior for Vercel when deploying a project unless you specify otherwise.

Why does it deploy to production and become public?

  1. Vercel's Default Behavior: When you run the vercel command without additional flags, Vercel assumes you want to deploy the latest version of your code to the Production environment. This deployment is public by default.

  2. No Environment Specification: Since you didn't specify a particular environment (like Preview or Development), Vercel deploys to Production by default.

  3. Public URL: Vercel provides a public URL for the deployed project, which is accessible by anyone who knows the URL.

How to Deploy to Preview or Development Environments

If you wish to deploy your project to a non-production environment (like Preview or Development), you can specify that when running the vercel command:

vercel --prod          # Deploys to Production (default behavior)
vercel --target=preview # Deploys to the Preview Environment
vercel --target=development # Deploys to the Development Environment

How to Make Your Project Private

If you want to prevent your project from being publicly accessible:

  1. Private Repositories: If you deploy from a private Git repository, the project on Vercel will still be public by default. However, you can restrict access using Vercel's security features.

  2. Password Protection: You can set up password protection for your project using Vercel's environment variables, custom domains, and Vercel's built-in password protection feature.

  3. Environment Variables: Ensure sensitive data like API keys are stored in environment variables (as you did with OPENAI_API_KEY). These won't be exposed in the public URL.

Steps to Restrict Public Access:

  1. Use Environment Variables Correctly: Make sure all sensitive information is stored in environment variables and not hard-coded in your codebase.

  2. Password Protect the Site:

    • Go to your project settings on Vercel.
    • Under the "Security" section, you can set up password protection for your deployments.
  3. Custom Domains and DNS: You can set up a custom domain and configure DNS records to control access more granularly.

  4. Access Controls: Use Vercel's access control features to limit who can view or deploy the project.

Example of Deploying to Preview Environment

vercel --target=preview

This command will deploy your project to the Preview environment, which is useful for testing purposes before deploying to Production.

Conclusion

By understanding Vercel's default behavior and utilizing environment-specific deployments, you can better control when and how your project becomes publicly accessible. If you need to restrict access, consider using password protection or other security features offered by Vercel.

ionescu77 commented 2 weeks ago

Deployment protection

https://vercel.com/docs/security/deployment-protection