implement staging workflow
This commit is contained in:
32
app-expo/plugins/withAndroidCleartextTraffic.js
Normal file
32
app-expo/plugins/withAndroidCleartextTraffic.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// @ts-check
|
||||
/**
|
||||
* Toggle Android cleartext HTTP traffic from Expo env.
|
||||
*
|
||||
* Staging may use an IP:port HTTP endpoint while production remains HTTPS.
|
||||
*/
|
||||
const { withAndroidManifest } = require('@expo/config-plugins');
|
||||
|
||||
/**
|
||||
* @param {import('expo/config').ExpoConfig} config
|
||||
* @param {{ enabled?: boolean }} props
|
||||
*/
|
||||
function withAndroidCleartextTraffic(config, props = {}) {
|
||||
return withAndroidManifest(config, (mod) => {
|
||||
const mainApplication = mod.modResults.manifest.application?.[0];
|
||||
|
||||
if (!mainApplication) {
|
||||
throw new Error(
|
||||
'[withAndroidCleartextTraffic] Main application not found in AndroidManifest.xml.',
|
||||
);
|
||||
}
|
||||
|
||||
mainApplication.$ = mainApplication.$ ?? {};
|
||||
mainApplication.$['android:usesCleartextTraffic'] = props.enabled
|
||||
? 'true'
|
||||
: 'false';
|
||||
|
||||
return mod;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = withAndroidCleartextTraffic;
|
||||
Reference in New Issue
Block a user