mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-13 18:55:23 +00:00
use polka again
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
import { resolve } from 'url';
|
||||
import express from 'express';
|
||||
import polka from 'polka';
|
||||
import compression from 'compression';
|
||||
import sapper from 'sapper';
|
||||
import serve from 'serve-static';
|
||||
import fetch from 'node-fetch';
|
||||
import { basepath, routes } from './manifest/server.js';
|
||||
import { routes } from './manifest/server.js';
|
||||
|
||||
const { PORT } = process.env;
|
||||
|
||||
// this allows us to do e.g. `fetch('/api/blog-posts')` on the server
|
||||
global.fetch = (url, opts) => {
|
||||
url = resolve(`http://localhost:${PORT}${basepath}/`, url);
|
||||
url = resolve(`http://localhost:${PORT}/`, url);
|
||||
return fetch(url, opts);
|
||||
};
|
||||
|
||||
express()
|
||||
polka()
|
||||
.use(compression({ threshold: 0 }))
|
||||
.use(basepath, serve('assets'))
|
||||
.use(sapper({ routes }))
|
||||
.use(serve('assets'), sapper({ routes }))
|
||||
.listen(PORT);
|
||||
@@ -14,7 +14,6 @@
|
||||
"dependencies": {
|
||||
"compression": "^1.7.1",
|
||||
"cross-env": "^5.1.3",
|
||||
"express": "^4.16.3",
|
||||
"node-fetch": "^2.0.0",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"polka": "^0.3.4",
|
||||
|
||||
Reference in New Issue
Block a user