Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Support base paths #180

Closed
Rich-Harris opened this issue Mar 9, 2018 · 0 comments
Closed

Support base paths #180

Rich-Harris opened this issue Mar 9, 2018 · 0 comments

Comments

@Rich-Harris
Copy link
Member

Use case: you want to serve a Sapper app from somewhere other than the root of your website. On the server this is relatively straightforward:

import polka from 'polka';
import sapper from 'sapper';
// ...
import { routes } from './manifest/server.js';

const app = polka();
const subapp = polka();

// ...

subapp.use(sapper({
  routes
}));

app.use('/subapp', subapp);

app.listen(4567);

This will (or should — I haven't actually tested it) mount e.g. routes/foo.html to /subapp/foo.

All that's missing, in theory, is for the client-side app to know about the base path. Proposed API:

import { init } from 'sapper/runtime.js';
import { routes } from './manifest/client.js';

init(document.querySelector('#sapper'), routes, {
  base: 'subapp'
});
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant