Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(mobile): isolate development app identity (#1475)

Corentin Thomassete338871f2606
diff --git a/apps/mobile/README.md b/apps/mobile/README.md
index 2566fc3d..cfbd21ad 100644
--- a/apps/mobile/README.md
+++ b/apps/mobile/README.md
@@ -2,6 +2,27 @@
React Native mobile application for Papra document management platform, built with Expo.
+## Local development
+
+Run `pnpm android` or `pnpm ios` from this directory to install **Papra Dev** alongside the store app. Development builds use separate application IDs (`app.papra.android.dev` / `app.papra.ios.dev`), app data, and the `papra-dev` URL scheme to avoid authentication callbacks opening the store app. `pnpm start` also selects the development variant, as does the EAS `development` profile. Production and preview builds retain the store app's identity.
+
+If you already have generated native projects, regenerate them once before running the development app:
+
+```sh
+APP_VARIANT=development pnpm exec expo prebuild --clean --platform android
+pnpm android
+```
+
+For iOS, use `--platform ios` and `pnpm ios` instead. `--clean` replaces the generated native project, so preserve any manual native changes first. Regenerate again whenever switching between development and production variants; Expo does not automatically update existing native projects when the application ID changes.
+
+The server must trust `papra-dev://` for development app authentication, including when testing against production. This is included in the server defaults. If `TRUSTED_APP_SCHEMES` is explicitly configured, it overrides those defaults; add the development scheme while preserving any other trusted schemes:
+
+```sh
+TRUSTED_APP_SCHEMES=papra://,exp://,papra-dev://
+```
+
+Deploy/restart the server after changing its configuration. If you previously built the development app with the `papra` scheme, regenerate and rebuild its native project using the commands above.
+
## Android release
```
diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts
index 58dc5120..6169803e 100644
--- a/apps/mobile/app.config.ts
+++ b/apps/mobile/app.config.ts
@@ -1,18 +1,34 @@
import type { ExpoConfig } from 'expo/config';
import { version } from './package.json';
+const isDevelopment = process.env.APP_VARIANT === 'development';
+
+const profile = isDevelopment
+ ? {
+ name: 'Papra - dev',
+ scheme: 'papra-dev',
+ ios: { bundleIdentifier: 'app.papra.ios.dev' },
+ android: { package: 'app.papra.android.dev' },
+ }
+ : {
+ name: 'Papra',
+ scheme: 'papra',
+ ios: { bundleIdentifier: 'app.papra.ios' },
+ android: { package: 'app.papra.android' },
+ };
+
const config: ExpoConfig = {
- name: 'Papra',
+ name: profile.name,
slug: 'papra',
version,
orientation: 'portrait',
icon: './src/assets/images/icon.png',
- scheme: 'papra',
+ scheme: profile.scheme,
userInterfaceStyle: 'automatic',
newArchEnabled: true,
ios: {
supportsTablet: true,
- bundleIdentifier: 'app.papra.ios',
+ bundleIdentifier: profile.ios.bundleIdentifier,
icon: {
dark: './src/assets/images/icon-dark.png',
light: './src/assets/images/icon-light.png',
@@ -28,7 +44,7 @@ const config: ExpoConfig = {
},
edgeToEdgeEnabled: true,
predictiveBackGestureEnabled: false,
- package: 'app.papra.android',
+ package: profile.android.package,
},
plugins: [
'expo-router',
diff --git a/apps/mobile/eas.json b/apps/mobile/eas.json
index 7b6df0ec..10218247 100644
--- a/apps/mobile/eas.json
+++ b/apps/mobile/eas.json
@@ -15,6 +15,9 @@
},
"development": {
"extends": "production",
+ "env": {
+ "APP_VARIANT": "development"
+ },
"developmentClient": true,
"distribution": "internal",
"autoIncrement": false
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index 2510d437..e7fa3075 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -7,9 +7,9 @@
"main": "expo-router/entry",
"scripts": {
"dev": "pnpm start",
- "start": "expo start",
- "android": "expo run:android",
- "ios": "expo run:ios",
+ "start": "APP_VARIANT=development expo start",
+ "android": "APP_VARIANT=development expo run:android",
+ "ios": "APP_VARIANT=development expo run:ios",
"typecheck": "tsc --noEmit",
"test": "vitest run",
"test:watch": "vitest watch"
diff --git a/apps/papra-server/src/modules/config/config.ts b/apps/papra-server/src/modules/config/config.ts
index 482b8d28..cf0cfa53 100644
--- a/apps/papra-server/src/modules/config/config.ts
+++ b/apps/papra-server/src/modules/config/config.ts
@@ -117,7 +117,7 @@ export const configDefinition = {
trustedAppSchemes: {
doc: 'A comma separated list of app schemes that are trusted for authentication. For example: "papra://,exp://". Note, setting this value will override the default schemes, so make sure to include them if needed.',
schema: appSchemeSchema,
- default: ['papra://', 'exp://'],
+ default: ['papra://', 'exp://', 'papra-dev://'],
env: 'TRUSTED_APP_SCHEMES',
},
port: {