feat(#740): Add hints for local bruno setup

- Custom error when opening bruno in the browser
- Custom error when starting electron without the web server running
- Force Next dev server to use port 3000
This commit is contained in:
Its-treason 2023-10-24 18:40:01 +02:00
parent 5274d77660
commit 7b1223d2c5
3 changed files with 25 additions and 2 deletions

View File

@ -3,7 +3,7 @@
"version": "0.3.0",
"private": true,
"scripts": {
"dev": "cross-env ENV=dev next dev",
"dev": "cross-env ENV=dev next dev -p 3000",
"build": "next build && next export",
"start": "next start",
"lint": "next lint",

View File

@ -41,6 +41,15 @@ function MyApp({ Component, pageProps }) {
return null;
}
if (!window.ipcRenderer) {
return (
<div style={{ color: 'red' }}>
Error: "ipcRenderer" not found in window object. You most likely opened Bruno inside your web browser. Bruno
only works within Electron, you can start Electron using "npm run dev:electron".
</div>
);
}
return (
<ErrorBoundary>
<SafeHydrate>

View File

@ -67,7 +67,21 @@ app.on('ready', async () => {
slashes: true
});
mainWindow.loadURL(url);
mainWindow.loadURL(url).catch((reason) => {
console.error(`Error: Failed to load URL: "${url}" (Electron shows a blank screen because of this).`);
console.error('Original message:', reason);
if (isDev) {
console.error(
'Could not connect to Next.Js dev server, is it running?' +
' Start the dev server using "npm run dev:web" and restart electron'
);
} else {
console.error(
'If you are using an official production build: the above error is most likely a bug! ' +
' Please report this under: https://github.com/usebruno/bruno/issues'
);
}
});
watcher = new Watcher();
const handleBoundsChange = () => {