capacitor-community/http was replaced by a 1st party HTTP plugin - Http Capacitor Plugin API | Capacitor Documentation. But, I would recommend sticking with the web layer for your calls if at all possible (see this post for why).
You could set a global var from an env variable to set your base URL. Something like (example using Vite):
interface ConfigInterface {
isDebug: boolean
baseApiUrl: string
}
export const Config: ConfigInterface = {
isDebug: import.meta.env.MODE !== 'production',
baseApiUrl: import.meta.env.VITE_BASE_API_URL as string,
}
fetch(`${Config.baseApiUrl}/api/foods/${foodId}`)
# .env
VITE_BASE_API_URL=https://example.com/api/v1/mobile
Or what we do, is use Axios which allows setting a baseUrl - Config Defaults | Axios Docs. We also set this as above with a config and env var.