maoberlehner / goodbye-webpack-building-vue-applications-without-webpack

This is an example project for the following article: https://markus.oberlehner.net/blog/goodbye-webpack-building-vue-applications-without-webpack/
76 stars 17 forks source link

CORS issues with Browsersync #4

Open rusco opened 5 years ago

rusco commented 5 years ago

Hi maoberlehner, on my Win10 /Chrome70 Box I ran into issues regarding CORS with the browser-sync package, even the "--cors" flag did not help. I couldn't serve the index.html page.

Then I tried your solution with the live-server package and it works like a charm. Just in case anybody encounters the same issues like me, try "live-server", put this script in the root folder:

const liveServer = require("live-server");

const params = {
    port: 8080, // Set the server port. Defaults to 8080.
    host: "0.0.0.0", // Set the address to bind to. Defaults to 0.0.0.0 or process.env.IP.
    root: "src", // Set root directory that's being served. Defaults to cwd.
    open: true, // When false, it won't load your browser by default.
    ignore: "scss,my/templates", // comma-separated string for paths to ignore
    file: "index.html", // When set, serve this file for every 404 (useful for single-page applications)
    wait: 1000, // Waits for all changes, before reloading. Defaults to 0 sec.
    //mount: [['/components', './node_modules']], // Mount a directory to a route.
    logLevel: 2, // 0 = errors only, 1 = some, 2 = lots
    middleware: [
        function(req, res, next) {
            next();
        }
    ] // Takes an array of Connect-compatible middleware that are injected into the server middleware stack
};
liveServer.start(params);

Dependencies in package.json:

"dependencies": {
        "live-server": "^1.2.1"
    }
maoberlehner commented 5 years ago

Thank you for letting us know!