Я создаю свое первое asp.net core
приложение, интегрированное с webpack 4
и webpack-dev-server 3
с использованием https mode .Но когда я запускаю dev-server
с помощью Chrome, он предупреждает меня следующим сообщением:
NET::ERR_CERT_AUTHORITY_INVALID
This server failed to prove that it is localhost; the relevant security certificate is not trusted by the computer operating system. The problem may be due to an incorrect configuration or to an attacker who intercepts the connection.
На консоли Chrome DevTools:
GET https://localhost:8085/main.bundle.js net::ERR_CERT_AUTHORITY_INVALID
Это моя package.json
конфигурация скриптов:
"scripts": {
"start": "webpack-dev-server --https --inline --progress -d --hot --config webpack.dev.config.js --watch",
"build": "SET NODE_ENV=dev & webpack -p --config webpack.config.js --progress"
},
Это мой webpack.dev.config.js
:
const path = require('path');
const webpack = require('webpack');
const ip = require('ip');
const MODULE_BUILD_DIR = path.resolve(__dirname, './wwwroot/dist/assets/');
const MODULE_BUILD_CSS_DIR = path.resolve(__dirname, './wwwroot/dist/assets/styles');
const MODULE_APP_JS_DIR = path.resolve(__dirname, './wwwroot/Scripts/');
const MODULE_APP_CSS_DIR = path.resolve(__dirname, '.wwwroot/less/');
const NODE_MODULE_DIR = path.resolve(__dirname, './node_modules/');
const AutoDllPlugin = require('autodll-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const config = {
mode: "development",
context: __dirname, // string (absolute path!)
entry: [
'webpack-dev-server/client?https://' + ip.address() + ':8085/',
'webpack/hot/only-dev-server',
path.resolve(__dirname, './wwwroot/Scripts/main.js')
],
output: {
path: MODULE_BUILD_DIR,
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/, // exclude the node_module directory
loader: 'babel-loader', // use this (babel-code) loader
},
{
test: /\.less$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "less-loader",
options: {
javascriptEnabled: true
}
}]
},
{
test: /\.jsx$/, // all files ending with .jsx
loader: 'babel-loader', // use the babel-loader for all .jsx files
exclude: /node_modules/, // exclude searching for files in the node_modules directory
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
use: ['file-loader']
},
],
},
resolve: {
modules: [
'node_modules',
path.resolve(MODULE_APP_JS_DIR), //__dirname, 'wwwroot/Scripts'
],
extensions: ['.js', '.json', '.jsx', '.css'],
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
],
devServer: {
https: true,
contentBase: path.resolve(__dirname, './'), // a directory or url to serve HTML content from
historyApiFallback: false, // fallback to /index.html for Single Page Applications
inline: true, // inline mode (set to false to disable including client scripts (like livereload))
open: true, // open default browser while lanching
port: 8085,
hot: true,
},
devtool: 'eval-source-map', // enable devtool for better debugging experience
};
module.exports = config;
Это запись в веб-пакете на моем _Layout.cshtml
:
<script type="text/javascript" src="https://localhost:8085/main.bundle.js"></script>
Мой Program
класс:
public static void Main(string[] args)
{
var host = CreateWebHostBuilder(args)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
И наконец мой Startup
класс Configure
метод:
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
Как вы думаете, в чем проблема?заранее большое спасибо за помощь!