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

[Bug]: How do I distinguish between a local run and a deployment in code? #1929

Open
1 task done
jymchng opened this issue Dec 17, 2024 · 1 comment
Open
1 task done
Labels
S-Triage Awaiting decision for what to do T-Bug Something isn't working

Comments

@jymchng
Copy link

jymchng commented Dec 17, 2024

What happened?

Suppose I want to distinguish a local run and a deployment, because I want to set different CORS Origins depending on whether I am running locally or not, how do I do so?

I note that shuttle_runtime::Environment is public but there is no variable that I can use to match it against during the runtime.

Version

cargo-shuttle 0.49.0

Which operating system(s) are you seeing the problem on?

Linux

Which CPU architectures are you seeing the problem on?

No response

Relevant log output

No response

Duplicate declaration

  • I have searched the issues and there are none like this.
@jymchng jymchng added S-Triage Awaiting decision for what to do T-Bug Something isn't working labels Dec 17, 2024
@jonaro00
Copy link
Member

jonaro00 commented Dec 17, 2024

You can get the Environment through https://docs.rs/shuttle-runtime/latest/shuttle_runtime/struct.Metadata.html (minor changes to its public interface are due soon). You can also check if you are running on Shuttle by checking for the SHUTTLE=true env var or use #[cfg(debug_assertions)] depending on use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Triage Awaiting decision for what to do T-Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants