mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-18 05:25:08 +00:00
move old docs over
This commit is contained in:
28
site/content/docs/13-base-urls.md
Normal file
28
site/content/docs/13-base-urls.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
title: Base URLs
|
||||
---
|
||||
|
||||
Ordinarily, the root of your Sapper app is served at `/`. But in some cases, your app may need to be served from a different base path — for example, if Sapper only controls part of your domain, or if you have multiple Sapper apps living side-by-side.
|
||||
|
||||
This can be done like so:
|
||||
|
||||
```js
|
||||
// app/server.js
|
||||
|
||||
express() // or Polka, or a similar framework
|
||||
.use(
|
||||
'/my-base-path', // <!-- add this line
|
||||
compression({ threshold: 0 }),
|
||||
serve('assets'),
|
||||
sapper.middleware()
|
||||
)
|
||||
.listen(process.env.PORT);
|
||||
```
|
||||
|
||||
Sapper will detect the base path and configure both the server-side and client-side routers accordingly.
|
||||
|
||||
If you're [exporting](guide#exporting) your app, you will need to tell the exporter where to begin crawling:
|
||||
|
||||
```bash
|
||||
sapper export --basepath my-base-path
|
||||
```
|
||||
Reference in New Issue
Block a user