Skip to content

Axios Environment Setup for Localhost + Vercel (Frontend & Backend) (config/axios-call) #71

@tran2106

Description

@tran2106

Allow Axios to automatically use the correct base URL depending on whether the app is running locally or deployed on Vercel.

Frontend

  • Set up environment variables for the backend URL (VITE_BACKEND_URL) in both local .env file and Vercel project settings.

  • Ensure Axios is initialized with the base URL from the environment variable.

  • Implement a fallback strategy for when the environment variable is not defined.

Test Axios requests locally and on Vercel to confirm everything works correctly across environments.

Backend

  • Set up environment variables for the frontend origin (FRONTEND_URL) in both local .env and Vercel dashboard.

  • Update CORS settings to allow the appropriate frontend origin depending on the environment.

  • Confirm that API requests from both local and deployed frontends are accepted without CORS or credential issues.

Metadata

Metadata

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions