# Hardcoded URLs in the code
*Exposure*
Move base URLs and callback URLs out of the code and into environment variables.

## Why it matters
A localhost or staging URL in the code breaks production and can send users to the wrong environment.
One setting per environment avoids editing code for every deploy and prevents a test URL from going live.

## How to fix it
1. Search for http://, localhost, and staging domains in the code
2. Move the base URL and callbacks to environment variables
3. Set a different value for each environment

## Prompt for an AI assistant
Copy the text below and paste it into an AI assistant.
```text
You are the person improving this website. Check the item below and fix it if it applies to the site.

Item: Hardcoded URLs in the code
Summary: Move base URLs and callback URLs out of the code and into environment variables.
Steps:
1. Search for http://, localhost, and staging domains in the code
2. Move the base URL and callbacks to environment variables
3. Set a different value for each environment
References:
- The Twelve-Factor App: Config (https://12factor.net/config)

Constraints:
- Keep the existing design and tone of voice.
- Show the file or section you changed and the suggested final wording.
- Do not decide ambiguous points alone; give options and a recommendation.
- Do not change anything outside the listed item.
```

## Related checks
- **[Environment variable names do not match](https://ismyappok.com/en/checks/env-config-mismatch)** — Make sure the variable names used in code match the names configured in the hosting environment.
- **[Endpoints without authentication](https://ismyappok.com/en/checks/unauthenticated-endpoint)** — Make sure every server function checks who is calling before it reads or writes data.

## References
- **[The Twelve-Factor App: Config](https://12factor.net/config)** — The Twelve-Factor App（Reference）

## Check your site now
Enter a URL and find what is missing before launch, for free.
[Run audit](https://ismyappok.com/en/audit/check)