Skip to content

🧹 Remove hardcoded API URL fallback and add environment validation#7

Merged
davidraehles merged 3 commits intomainfrom
cleanup/remove-hardcoded-api-url-fallback-8975384767320290455
Feb 18, 2026
Merged

🧹 Remove hardcoded API URL fallback and add environment validation#7
davidraehles merged 3 commits intomainfrom
cleanup/remove-hardcoded-api-url-fallback-8975384767320290455

Conversation

@davidraehles
Copy link
Copy Markdown
Collaborator

🎯 What: Removed the hardcoded fallback value for the API URL in the frontend and replaced it with a strict environment variable requirement.
💡 Why: This ensures that the application configuration is strictly managed via the environment, preventing accidental connections to the wrong backend and improving maintainability. Added validation ensures the app fails fast with a clear error message if the configuration is missing.
Verification:

  • Verified that VITE_API_URL is correctly read from the environment.
  • Added a .env.example file for documentation.
  • Updated the test suite to mock the environment variable, ensuring all tests pass.
  • Verified that no pre-existing functionality is broken.
    Result: Improved configuration health and robust environment variable handling.

PR created automatically by Jules for task 8975384767320290455 started by @davidraehles

- Removed 'http://localhost:3000' fallback for VITE_API_URL in frontend/src/services/api.ts
- Added runtime check to throw an error if VITE_API_URL is not defined
- Created frontend/.env.example to document required environment variables
- Updated frontend/src/test/setup.ts to mock VITE_API_URL for tests

Co-authored-by: davidraehles <6085055+davidraehles@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings February 18, 2026 19:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens frontend configuration by removing the hardcoded API base URL fallback and enforcing VITE_API_URL as a required environment variable so the app fails fast when misconfigured.

Changes:

  • Removed the http://localhost:3000 fallback and added a runtime validation/throw when VITE_API_URL is missing.
  • Updated Vitest setup to stub VITE_API_URL for the test environment.
  • Added frontend/.env.example documenting the required variable.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
frontend/src/services/api.ts Enforces VITE_API_URL presence and removes the hardcoded localhost fallback.
frontend/src/test/setup.ts Stubs VITE_API_URL so importing the API client in tests doesn’t throw.
frontend/.env.example Documents the required VITE_API_URL env var for local/dev setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/test/setup.ts Outdated
*/

import { expect, afterEach } from 'vitest';
import { expect, afterEach, vi } from 'vitest';
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect is imported but never used in this setup file (Vitest globals are enabled in vite.config.ts, and this file already imports from vitest for afterEach/vi). This will trip @typescript-eslint/no-unused-vars; remove expect from the import (or disable the rule for this line if you intentionally want the binding).

Suggested change
import { expect, afterEach, vi } from 'vitest';
import { afterEach, vi } from 'vitest';

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unused expect import from test setup.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I've removed the unused expect import from the test setup.

David and others added 2 commits February 18, 2026 21:16
@davidraehles davidraehles merged commit b923f70 into main Feb 18, 2026
davidraehles added a commit that referenced this pull request Feb 18, 2026
…6-7-8-10-11-12-13-14

Merge PRs #1, #2, #3, #4, #5, #6, #7, #8, #10, #11, #12, #13, #14 into main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants