Skip to content
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

feat(server): Add dev mode env var #1404

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

wtchen
Copy link

@wtchen wtchen commented Jul 4, 2023

I'm hoping this small feature will be useful for people to develop against dev and production environments.

This will also help kick off #1321, which needs this distinction.

@bartlomieju
Copy link
Member

I believe I was wrong in my original comment in #1321 - Fresh already decides if it is in devmode or not based on DENO_DEPLOYMENT_ID env var.

@wtchen
Copy link
Author

wtchen commented Jul 4, 2023

Ah, good catch. I think having something explicit would still be useful; I can turn this into an abstraction.

@wtchen
Copy link
Author

wtchen commented Jul 4, 2023

Ok, I made some changes, let me know what you think 🙂

@marvinhagemeister
Copy link
Collaborator

I'm not sure I understand what we gain from exposing if Fresh is in dev mode via an environment variable. Can you share more about your use case?

@wtchen
Copy link
Author

wtchen commented Jul 4, 2023

Of course. The idea is if the user wants to have different code for dev vs not dev, they can easily check against that env variable.

if (Deno.env.get("FRSH_DEVMODE") === 'true') {
  return new Response('Welcome to my dev site');
} else {
  return new Response('Welcome to my production site');
}
@lucacasonato
Copy link
Member

Could that usecase be resolved by a per-project env var?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants