Skip to content

Commit

Permalink
fix(Routing): Avoid resolving client-side routes as filepaths
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-ketch committed May 21, 2021
1 parent 495a2b6 commit 41408be
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
8 changes: 2 additions & 6 deletions desktop/src/app/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ export const createWindow = (
options: Omit<BrowserWindowConstructorOptions, 'webPreferences'> = {}
): BrowserWindow => {
const win = new BrowserWindow({
height: 430,
width: 860,
maxHeight: 860,
maxWidth: 1200,
minHeight: 350,
minWidth: 600,
height: 860,
width: 1024,
title: i18n.t('core.title'),
...options,
webPreferences: {
Expand Down
9 changes: 8 additions & 1 deletion desktop/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ const createMainWindow = (): void => {
protocol.registerBufferProtocol(scheme, requestHandler)

const mainWindowUrl = '/'
const mainWindow = createWindow(mainWindowUrl)
const mainWindow = createWindow(mainWindowUrl, {
height: 430,
width: 860,
maxHeight: 860,
maxWidth: 1200,
minHeight: 350,
minWidth: 600,
})

store = initStore(mainWindow)
}
Expand Down
4 changes: 3 additions & 1 deletion desktop/src/main/app-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const requestHandler: RequestHandler = (req, next) => {
const reqUrl = new URL(req.url)
let reqPath = path.resolve(reqUrl.pathname)

if (reqPath === '/') {
// This is necessary to avoid trying to resolve dynamic routes as file on the filesystem
// TODO: Investigate a more refined way of detecting if we’re loading an asset or a route within the app.
if (reqPath === '/' || !reqPath.includes('.')) {
reqPath = '/main_window/index.html'
}

Expand Down
2 changes: 1 addition & 1 deletion desktop/src/renderer/global/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Any global CSS variables should also be applied here.
*/

@import url('https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css');
@import url('https://unpkg.com/remixicon@2.5.0/fonts/remixicon.css');
@import '../components/shared/scrollbars.css';

:root {
Expand Down
6 changes: 5 additions & 1 deletion desktop/webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ module.exports = {
'https://fonts.googleapis.com/',
],
'connect-src': "'self'",
'font-src': ["'self'", 'https://fonts.gstatic.com/'],
'font-src': [
"'self'",
'https://fonts.gstatic.com/',
'https://unpkg.com/',
],
},
{
hashEnabled: {
Expand Down

0 comments on commit 41408be

Please sign in to comment.