25 lines
720 B
TypeScript
25 lines
720 B
TypeScript
import type { ConfigContext, ExpoConfig } from "expo/config";
|
|
|
|
export default ({ config }: ConfigContext): ExpoConfig => {
|
|
if (process.env.EAS_BUILD_PROFILE === "production") {
|
|
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
|
|
if (!apiUrl) {
|
|
throw new Error(
|
|
"EXPO_PUBLIC_API_URL must be set in the EAS production environment before building for the App Store.",
|
|
);
|
|
}
|
|
|
|
let parsed: URL;
|
|
try {
|
|
parsed = new URL(apiUrl);
|
|
} catch {
|
|
throw new Error("EXPO_PUBLIC_API_URL must be a valid URL.");
|
|
}
|
|
if (parsed.protocol !== "https:") {
|
|
throw new Error("EXPO_PUBLIC_API_URL must use HTTPS for production builds.");
|
|
}
|
|
}
|
|
|
|
return config as ExpoConfig;
|
|
};
|