@@ -40,6 +40,7 @@ and [old][Old Architecture] RN architectures.
40
40
[ getDeviceType() ] : https://www.npmjs.com/package/react-native-device-info#getDeviceType
41
41
[ MainBundlePath ] : https://www.npmjs.com/package/@dr.pogodin/react-native-fs#mainbundlepath
42
42
[ mod_alias ] : https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_alias
43
+ [ mod_rewrite ] : https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_rewrite
43
44
[ mod_webdav ] : https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_webdav
44
45
[ react-native-device-info ] : https://www.npmjs.com/package/react-native-device-info
45
46
[ react-native-fs ] : https://www.npmjs.com/package/react-native-fs
@@ -50,8 +51,9 @@ and [old][Old Architecture] RN architectures.
50
51
## Content
51
52
52
53
- [ Getting Started] ( #getting-started )
53
- - [ Bundling-in Server Assets Into an App Statically] ( #bundling-in-server-assets-into-an-app-statically )
54
+ - [ Bundling-in Server Assets Into an App Statically]
54
55
- [ Enabling Alias module]
56
+ - [ Enabling Rewrite module]
55
57
- [ Enabling WebDAV module]
56
58
- [ API Reference] ( #api-reference )
57
59
- [ Project History and Roadmap] ( #project-history-and-roadmap )
@@ -219,6 +221,7 @@ and [old][Old Architecture] RN architectures.
219
221
```
220
222
221
223
### Bundling-in Server Assets Into an App Statically
224
+ [Bundling-in Server Assets Into an App Statically]: #bundling-in-server-assets-into-an-app-statically
222
225
223
226
The assets to be served by the server may come to the target device in different
224
227
ways, for example, they may be generated during the app' s runtime, or downloaded
@@ -360,10 +363,29 @@ root for a given url-subset. To enable it just use `extraConfig` option of
360
363
[Server] [constructor()] to load and configure it, for example:
361
364
362
365
` ` ` ts
363
- extraConfig: `
364
- server.modules += (" mod_alias" )
365
- alias.url = (" /sample/url" => " /special/root/path" )
366
- ` ,
366
+ extraConfig: `
367
+ server.modules += (" mod_alias" )
368
+ alias.url = (" /sample/url" => " /special/root/path" )
369
+ ` ,
370
+ ` ` `
371
+
372
+ # ## Enabling Rewrite Module
373
+ [Enabling Rewrite module]: # enabling-rewrite-module
374
+
375
+ [Lighttpd]'s module [mod_rewrite] can be used for interal redirects,
376
+ URL rewrites by the server. To enable it just use ` extraConfig` option of
377
+ [Server] [constructor()] to load and configure it, for example:
378
+
379
+ ` ` ` ts
380
+ extraConfig: `
381
+ server.modules += (" mod_rewrite" )
382
+ url.rewrite-once = (" /some/path/(.*)" => " /$1 " )
383
+ ` ,
384
+
385
+ // With such configuration, for example, a request
386
+ // GET " /some/path/file"
387
+ // will be redirected to
388
+ // GET " /file"
367
389
` ` `
368
390
369
391
# ## Enabling WebDAV Module
@@ -376,6 +398,15 @@ _etc._ functionality for selected routes.
376
398
377
399
** BEWARE:** _As of now, props and locks are not supported._
378
400
401
+ ** BEWARE:** _If you have set up the server to serve static assets bundled into
402
+ the app, the chances are your server works with a readonly location on most
403
+ platforms (in the case of Android it is anyway necessary to unpack bundled
404
+ assets to the regular filesystem, thus there the server might be serving
405
+ from a writeable location already). The easiest way around it is to use
406
+ [mod_alias][Enabling Alias module] to point URLs configured for [mod_webdav]
407
+ to a writeable filesystem location, different from that of the served static
408
+ assets._
409
+
379
410
To enable [mod_webdav] in the library you need (1) configure your host RN app
380
411
to build Lighttpd with [mod_webdav] included; (2) opt-in to use it for selected
381
412
routes when you create [Server] instance, using ` extraConfig` option.
0 commit comments