Merge pull request #207 from sveltejs/fix-fetch-paths

fix server-side fetch paths
This commit is contained in:
Rich Harris
2018-03-18 22:41:01 -04:00
committed by GitHub
2 changed files with 1 additions and 2 deletions

View File

@@ -173,7 +173,7 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
error = { statusCode, message };
},
fetch: (url: string, opts?: any) => {
const parsed = new URL(url, `http://127.0.0.1:${process.env.PORT}${req.baseUrl}${req.path}`);
const parsed = new URL(url, `http://127.0.0.1:${process.env.PORT}${req.baseUrl ? req.baseUrl + '/' :''}`);
if (opts) {
opts = Object.assign({}, opts);

View File

@@ -3,7 +3,6 @@
<script>
export default {
preload({ query }) {
console.log(`here ${this.fetch}`);
return this.fetch(`credentials/test.json`, {
credentials: query.creds
}).then(r => r.json());