Skip to content

Commit

Permalink
fix(vercel): compat server url not root pathname
Browse files Browse the repository at this point in the history
  • Loading branch information
lizheming committed Dec 14, 2020
1 parent 0f92b8e commit 17d402c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/admin/src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export default async function request(url, opts = {}) {
opts.headers.Authorization = `Bearer ${token}`;
}

return fetch((globalThis.serverURL || '/')+ opts.url, opts).then(resp => {
const baseUrl = globalThis.serverURL || location.pathname.match(/(.*)?\/ui/)[1] || '/';
return fetch(baseUrl + opts.url, opts).then(resp => {
if(resp.ok) {
return resp.json();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = class extends think.Controller {
new Waline({
el: '#waline',
path: '/',
serverURL: location.protocol + '//' + location.host
serverURL: location.protocol + '//' + location.host + location.pathname.slice(1)
});
</script>
</body>
Expand Down

0 comments on commit 17d402c

Please sign in to comment.