use polka again

This commit is contained in:
Rich Harris
2018-03-17 10:55:02 -04:00
parent 3ba3cd515e
commit 0119b07e6b
2 changed files with 5 additions and 7 deletions

View File

@@ -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);

View File

@@ -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",