Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot GET / #27

Open
terion-name opened this issue Oct 5, 2018 · 11 comments
Open

Cannot GET / #27

terion-name opened this issue Oct 5, 2018 · 11 comments

Comments

@terion-name
Copy link

Version

v1.1.1

Reproduction link

https://github.com/terion-name/metod-admin-temp

Steps to reproduce

yarn build

What is expected ?

app works

What is actually happening?

Cannot GET /

Additional comments?

I've used this template, generated app. In dev mode everything works ok. But If I build the app I get this:
Скриншот 2018-10-05 11.53.58.png

package.json:

{
  "name": "metod-admin",
  "version": "1.0.0",
  "description": "METOD admin client",
  "author": "Terion <mail@terion.name>",
  "private": true,
  "main": "main.js",
  "build": {
    "appId": "com.metod-admin.app",
    "directories": {
      "buildResources": "static"
    }
  },
  "scripts": {
    "dev": "cross-env NODE_ENV=DEV electron .",
    "dev:web": "cross-env NODE_ENV=DEV BUILD_TARGET=web  nuxt",
    "build": "nuxt build && electron-builder",
    "build:web": "cross-env nuxt build",
    "start": "cross-env nuxt build && nuxt start"
  },
  "dependencies": {
    "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
    "@babel/plugin-proposal-optional-chaining": "^7.0.0",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
    "@babel/preset-env": "^7.1.0",
    "@babel/preset-flow": "^7.0.0",
    "apexcharts": "^2.0.9",
    "element-ui": "^2.4.7",
    "lockr": "^0.8.5",
    "nuxt": "^2.1.0",
    "nuxt-babel": "^0.1.2",
    "nuxt-i18n": "^5.3.0",
    "stylus": "^0.54.5",
    "stylus-loader": "^3.0.2",
    "underscore": "^1.9.1",
    "vue-apexcharts": "^1.2.1",
    "vue-lodash": "^2.0.0",
    "vue-wysiwyg": "^1.7.2",
    "vue2-editor": "^2.6.6",
    "vuedraggable": "^2.16.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.1",
    "cross-env": "^5.2.0",
    "electron": "2.0.0-beta.7",
    "electron-builder": "^20.8.1",
    "electron-devtools-installer": "^2.2.3",
    "eslint": "^4.15.0",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-vue": "^4.0.0"
  }
}
This bug report is available on Nuxt community (#c24)
@ghost ghost added the cmty:bug-report label Oct 5, 2018
@uucyan
Copy link

uucyan commented Oct 6, 2018

私も同じ問題を抱えています。
本番用のURLを設定する必要がありますか?

しかし、その本番用のURLが分かりません。

I have the same problem.
Is it necessary to set the URL for production?

However, I do not know the URL for production.

electron-template/template/main.js:

const _NUXT_URL_ = `http://localhost:${server.address().port}`
・・・
if (config.dev) {
・・・
} else { return win.loadURL(_NUXT_URL_) }

@tetreault
Copy link

did you guys ever resolve this? @uucyan @terion-name

cc: @pi0

@tetreault
Copy link

Mine seems to build w/o any issue after running npm run build. I have my .dmg file which installs the app to my mac as expected and it runs w/o your issue.

@terion-name
Copy link
Author

@tetreault nope :(

@uucyan
Copy link

uucyan commented Nov 22, 2018

@tetreault
nope😷

Because there is no choice, it was solved by the following method.
#20

@Hsinky
Copy link

Hsinky commented Jun 14, 2019

首先,非常感谢您的分享,但是,在使用过程种遇到了很多问题,如下:
1,用到了nuxtjs,那么就期待多端发布,如桌面app和website,可是命令中并不包含website的命令
2,期待在nuxtjs官方的模板下添加electron打包命令,且分成web和app两个目录

@michalzaq12
Copy link

For developers who are looking for a alternative solution:

https://github.com/michalzaq12/electron-nuxt

@vvkkhjt
Copy link

vvkkhjt commented Aug 27, 2019

const newWin = () => {
    win = new BrowserWindow({
        icon: path.join(__dirname, 'static/icon.png'),
        webPreferences: {
            nodeIntegration: true
        },
        width: 1920,
        height: 1080
    })

    win.on('closed', () => win = null)
    // Wait for nuxt to build
    const pollServer = () => {
        http.get(_NUXT_URL_, (res) => {
            if (res.statusCode === 200) {
                win.loadURL(_NUXT_URL_)
            } else {
                setTimeout(pollServer, 300)
            }
        }).on('error', pollServer)
    }
    if (config.dev) {
        // Install vue dev tool and open chrome dev tools
        const {
            default: installExtension,
            VUEJS_DEVTOOLS
        } = require('electron-devtools-installer')
        installExtension(VUEJS_DEVTOOLS.id).then(name => {
            console.log(`Added Extension:  ${name}`)
            win.webContents.openDevTools()
        }).catch(err => console.log('An error occurred: ', err))
        pollServer()
    } else {
        pollServer()
    }
}

this will work with production env

@Amaurgit
Copy link

Hey there ! Not working for me too. Any solution ? @Atinux 🙏

@Atinux
Copy link
Member

Atinux commented Mar 6, 2020

Sadly I don’t have time to debug on Electron :(

@krish-kant
Copy link

I am also facing same issue, it will be great if this can be fixed.🙏 @Atinux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants