Skip to content

Commit

Permalink
Fix redirect with basepath
Browse files Browse the repository at this point in the history
  • Loading branch information
thgh committed Mar 3, 2019
1 parent 9522cb4 commit 13b64cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion runtime/src/server/middleware/get_page_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function get_page_handler(

try {
if (redirect) {
const location = URL.resolve(req.baseUrl || '/', redirect.location);
const location = URL.resolve((req.baseUrl || '') + '/', redirect.location);

res.statusCode = redirect.statusCode;
res.setHeader('Location', location);
Expand Down
4 changes: 2 additions & 2 deletions test/apps/with-basepath/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('with-basepath', function() {
let page: puppeteer.Page;
let base: string;

// helpers
let start: () => Promise<void>;
let prefetchRoutes: () => Promise<void>;
let title: () => Promise<string>;
Expand Down Expand Up @@ -63,14 +64,13 @@ describe('with-basepath', function() {
'custom-basepath/global.css',
'custom-basepath/index.html',
'custom-basepath/redirect-from/index.html',
'custom-basepath/redirect-to',
'custom-basepath/redirect-to/index.html',
'custom-basepath/service-worker-index.html',
'custom-basepath/service-worker.js'
]);
});

it('redirects on server', async () => {
console.log('base', base)
await page.goto(`${base}/custom-basepath/redirect-from`);

assert.equal(
Expand Down

0 comments on commit 13b64cd

Please sign in to comment.