From 58642d57f6281dde1d224365c6c0b2b05085413b Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 21 Aug 2017 23:35:04 +0200 Subject: [web] make it possible to run static viewer in subdirectories --- web/src/js/__tests__/ducks/optionsSpec.js | 2 +- web/src/js/utils.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'web') diff --git a/web/src/js/__tests__/ducks/optionsSpec.js b/web/src/js/__tests__/ducks/optionsSpec.js index 9178c14e..d3f9b8e5 100644 --- a/web/src/js/__tests__/ducks/optionsSpec.js +++ b/web/src/js/__tests__/ducks/optionsSpec.js @@ -56,7 +56,7 @@ describe('save', () => { global.fetch = jest.fn() store.dispatch(OptionsActions.save()) expect(fetch).toBeCalledWith( - '/options/save?_xsrf=undefined', + './options/save?_xsrf=undefined', { credentials: "same-origin", method: "POST" diff --git a/web/src/js/utils.js b/web/src/js/utils.js index 3aeba1b1..7c1719ae 100644 --- a/web/src/js/utils.js +++ b/web/src/js/utils.js @@ -91,6 +91,9 @@ export function fetchApi(url, options={}) { } else { url += '.json' } + if (url.startsWith("/")) { + url = "." + url; + } return fetch(url, { credentials: 'same-origin', -- cgit v1.2.3