fix: url creation
This fixes #1238
I updated the name of the env variable from EXPO_PUBLIC_SERVER_ORIGIN to EXPO_PUBLIC_SERVER_URL since that is the name the docs mentions
Previously the code checked if window.location is defined, which threw an error because window did not exist, this caused it to fallback to the default URL without checking the env variable
The new code will check if the env variable FIRST and use it if it exists, then check safely for the window and then for the debuggerHost
Summary by CodeRabbit
-
Bug Fixes
- Improved server URL resolution to safely prefer the browser origin when available and reliably fall back to the debugger host when needed (avoids errors when a browser environment is absent).
-
Chores
- Replaced EXPO_PUBLIC_SERVER_ORIGIN with EXPO_PUBLIC_SERVER_URL for deriving the app’s server URL.
- Updated default resolution and runtime warnings to reference the new variable and clarify configuration expectations.
🦋 Changeset detected
Latest commit: 3f65cee9c2200f08b1b1d6b7565157521f80f862
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @uploadthing/expo | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
@HamzaNa1 is attempting to deploy a commit to the Ping Labs Team on Vercel.
A member of the Team first needs to authorize it.
Walkthrough
Replaces use of EXPO_PUBLIC_SERVER_ORIGIN with EXPO_PUBLIC_SERVER_URL and updates URL resolution to prefer EXPO_PUBLIC_SERVER_URL, then window.location.origin (when available), then http://{debuggerHost}. Adjusts warning message accordingly. No exported/public API changes.
Changes
| Cohort / File(s) | Summary |
|---|---|
Expo URL resolutionpackages/expo/src/index.ts |
Switched env var from EXPO_PUBLIC_SERVER_ORIGIN to EXPO_PUBLIC_SERVER_URL; updated URL construction fallback order (env → window.location.origin → http://{debuggerHost}); revised warning message text; minor structural alignment in URL construction. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant App
participant ExpoPkg as uploadthing/expo
participant Env as process.env
participant Window as window.location
participant Debugger as debuggerHost
App->>ExpoPkg: generateReactNativeHelpers(initOpts)
Note over ExpoPkg: Build base URL
ExpoPkg->>Env: Read EXPO_PUBLIC_SERVER_URL
alt EXPO_PUBLIC_SERVER_URL set
ExpoPkg->>ExpoPkg: Use env URL (absolute or resolve relative)
else not set
ExpoPkg->>Window: Check window.location.origin
alt window available
ExpoPkg->>ExpoPkg: Use window.location.origin
else no window
ExpoPkg->>Debugger: Use http://{debuggerHost}
end
end
ExpoPkg-->>App: Resolved URL (or warn on failure)
Note right of ExpoPkg: Warning references EXPO_PUBLIC_SERVER_URL
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches
❌ Failed checks (1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Title Check | ❓ Inconclusive | The title “fix: url creation” indicates a fix related to URL construction but is overly generic and does not clearly convey the primary changes around renaming the environment variable and updating the URL resolution logic. It only partially reflects the scope of the PR and may not immediately inform reviewers or future readers of the key modifications. Therefore, it is inconclusive whether this title sufficiently captures the main change. | Consider updating the title to explicitly reference the environment variable rename and the updated URL resolution logic, for example: “fix: use EXPO_PUBLIC_SERVER_URL and update URL fallback logic”. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Linked Issues Check | ✅ Passed | The changes rename the environment variable to EXPO_PUBLIC_SERVER_URL, update the URL resolution order to check the env variable before safely handling window availability, and adjust the warning message accordingly, fully addressing the coding requirements outlined in issue #1238. |
| Out of Scope Changes Check | ✅ Passed | All modifications are confined to the URL construction logic in packages/expo/src/index.ts, directly targeting the env variable rename and resolution flow described in the linked issue with no unrelated or extraneous changes. |
| Docstring Coverage | ✅ Passed | No functions found in the changes. Docstring coverage check skipped. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| docs-uploadthing | Preview | Comment | Oct 16, 2025 0:19am |
1 Skipped Deployment
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| legacy-docs-uploadthing | Oct 16, 2025 0:19am |
Update examples and turbo.json.
Keep old (incorrect) variable as a potential fallback to prevent issues for anyone who worked around this previously