Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 从远程计算机访问JHipster应用程序(在开发模式下运行)_Angular_Spring Boot_Configuration_Jhipster_Remote Access - Fatal编程技术网

Angular 从远程计算机访问JHipster应用程序(在开发模式下运行)

Angular 从远程计算机访问JHipster应用程序(在开发模式下运行),angular,spring-boot,configuration,jhipster,remote-access,Angular,Spring Boot,Configuration,Jhipster,Remote Access,我有一个JHipster应用程序在开发模式下运行。 它在后端使用弹簧靴,在前端使用角形6 为了在本地机器上运行应用程序,我使用“npm start”或“warn start”来启动客户端服务器和后端服务器,我从eclipseide运行springboot应用程序。 此设置在我的本地计算机上运行良好 但是我应该在应用程序中做什么更改才能从远程机器访问它呢? 我试图修改parent dir\webpack\webpack.dev.js使之生效,但没有成功。 我曾在某个地方读到,通过运行“ng ser

我有一个JHipster应用程序在开发模式下运行。 它在后端使用弹簧靴,在前端使用角形6

为了在本地机器上运行应用程序,我使用“npm start”或“warn start”来启动客户端服务器和后端服务器,我从eclipseide运行springboot应用程序。 此设置在我的本地计算机上运行良好

但是我应该在应用程序中做什么更改才能从远程机器访问它呢? 我试图修改parent dir\webpack\webpack.dev.js使之生效,但没有成功。 我曾在某个地方读到,通过运行“ng serve”可以进行远程访问,但据我所知,JHipster不支持此命令

下面是webpack.dev.js文件

const webpack = require('webpack');
const writeFilePlugin = require('write-file-webpack-plugin');
const webpackMerge = require('webpack-merge');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const path = require('path');
const sass = require('sass');

const utils = require('./utils.js');
const commonConfig = require('./webpack.common.js');

const ENV = 'development';

module.exports = (options) => webpackMerge(commonConfig({ env: ENV }), {
    devtool: 'eval-source-map',
    devServer: {
        contentBase: './target/www',
        proxy: [{
            context: [
                /* jhipster-needle-add-entity-to-webpack - JHipster will add entity api paths here */
                '/api',
                '/management',
                '/swagger-resources',
                '/v2/api-docs',
                '/h2-console',
                '/auth'
            ],
            target: `http${options.tls ? 's' : ''}://127.0.0.1:8080`,
            secure: false,
            changeOrigin: options.tls,
            headers: { host: 'localhost:9000' }
        }],
        stats: options.stats,
        watchOptions: {
            ignored: /node_modules/
        }
    },
    entry: {
        polyfills: './src/main/webapp/app/polyfills',
        global: './src/main/webapp/content/scss/global.scss',
        main: './src/main/webapp/app/app.main'
    },
    output: {
        path: utils.root('target/www'),
        filename: 'app/[name].bundle.js',
        chunkFilename: 'app/[id].chunk.js'
    },
    module: {
        rules: [{
            test: /\.ts$/,
            enforce: 'pre',
            loader: 'tslint-loader',
            exclude: ['node_modules', new RegExp('reflect-metadata\\' + path.sep + 'Reflect\\.ts')]
        },
        {
            test: /\.ts$/,
            use: [
                'angular2-template-loader',
                {
                    loader: 'cache-loader',
                    options: {
                      cacheDirectory: path.resolve('target/cache-loader')
                    }
                },
                {
                    loader: 'thread-loader',
                    options: {
                        // there should be 1 cpu for the fork-ts-checker-webpack-plugin
                        workers: require('os').cpus().length - 1
                    }
                },
                {
                    loader: 'ts-loader',
                    options: {
                        transpileOnly: true,
                        happyPackMode: true
                    }
                },
                'angular-router-loader'
            ],
            exclude: ['node_modules']
        },
        {
            test: /\.scss$/,
            use: ['to-string-loader', 'css-loader', {
                loader: 'sass-loader',
                options: { implementation: sass }
            }],
            exclude: /(vendor\.scss|global\.scss)/
        },
        {
            test: /(vendor\.scss|global\.scss)/,
            use: ['style-loader', 'css-loader', 'postcss-loader', {
                loader: 'sass-loader',
                options: { implementation: sass }
            }]
        },
        {
            test: /\.css$/,
            use: ['to-string-loader', 'css-loader'],
            exclude: /(vendor\.css|global\.css)/
        },
        {
            test: /(vendor\.css|global\.css)/,
            use: ['style-loader', 'css-loader']
        }]
    },
    stats: process.env.JHI_DISABLE_WEBPACK_LOGS ? 'none' : options.stats,
    plugins: [
        process.env.JHI_DISABLE_WEBPACK_LOGS
            ? null
            : new SimpleProgressWebpackPlugin({
                format: options.stats === 'minimal' ? 'compact' : 'expanded'
              }),
        new FriendlyErrorsWebpackPlugin(),
        new ForkTsCheckerWebpackPlugin(),
        new BrowserSyncPlugin({
            host: 'localhost',
            port: 9000,
            proxy: {
                target: 'http://localhost:9060'
            },
            socket: {
                clients: {
                    heartbeatTimeout: 60000
                }
            }
        }, {
            reload: false
        }),
        new webpack.ContextReplacementPlugin(
            /angular(\\|\/)core(\\|\/)/,
            path.resolve(__dirname, './src/main/webapp')
        ),
        new writeFilePlugin(),
        new webpack.WatchIgnorePlugin([
            utils.root('src/test'),
        ]),
        new WebpackNotifierPlugin({
            title: 'JHipster',
            contentImage: path.join(__dirname, 'logo-jhipster.png')
        })
    ].filter(Boolean),
    mode: 'development'
});

提前谢谢

默认情况下,webpack dev server侦听127.0.0.1,您必须将其配置为侦听0.0.0.0

编辑
webpack/webpack.dev.js
并将主机设置为0.0.0.0:

devServer: {
    host: '0.0.0.0',

谢谢你,盖尔。这意味着很多。我可以从远程机器访问主页,但当从用户登录页面登录时,它无法访问后端API。webpack.dev.js文件中是否还需要任何更改?我在问题中添加了一个未编辑版本的文件。谢谢你启动java应用程序了吗?webpack dev服务器将所有api调用代理到java后端,因此只要可以访问webpack并且java后端运行,它就应该工作。我的应用程序失败b/c这也失败-GET