You can configure axios globally to automatically include baseURL, token in headers etc
// context/auth.js
import axios from "axios";
import { API } from "../config";
// config axios
axios.defaults.baseURL = API;
Now you can remove API part from axios request.
// Register.js
// const { data } = await axios.post(`${API}/pre-register`, {
const { data } = await axios.post(`/pre-register`, {