mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 11:15:14 +00:00
29 lines
801 B
Markdown
29 lines
801 B
Markdown
---
|
|
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](docs#Exporting) your app, you will need to tell the exporter where to begin crawling:
|
|
|
|
```bash
|
|
sapper export --basepath my-base-path
|
|
```
|