<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="yarn run v1.3.2
$ rimraf node_modules/.cache/babel-loader &amp;&amp; next
/project/next.config.js:9
    config.entry = async () =&gt; {
                         ^
SyntaxError: Unexpected token (
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at loadConfig (/project/node_modules/next/dist/server/config.js:57:28)
    at getConfig (/project/node_modules/next/dist/server/config.js:40:20)
    at new HotReloader (/project/node_modules/next/dist/server/hot-reloader.js:119:40)
    at Server.getHotReloader (/project/node_modules/next/dist/server/index.js:157:14)
    at new Server (/project/node_modules/next/dist/server/index.js:124:35)
    at Object.&lt;anonymous&gt; (/project/node_modules/next/dist/bin/next-dev:63:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
error Command failed with exit code 1."><pre class="notranslate"><code class="notranslate">yarn run v1.3.2
$ rimraf node_modules/.cache/babel-loader &amp;&amp; next
/project/next.config.js:9
    config.entry = async () =&gt; {
                         ^
SyntaxError: Unexpected token (
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at loadConfig (/project/node_modules/next/dist/server/config.js:57:28)
    at getConfig (/project/node_modules/next/dist/server/config.js:40:20)
    at new HotReloader (/project/node_modules/next/dist/server/hot-reloader.js:119:40)
    at Server.getHotReloader (/project/node_modules/next/dist/server/index.js:157:14)
    at new Server (/project/node_modules/next/dist/server/index.js:124:35)
    at Object.&lt;anonymous&gt; (/project/node_modules/next/dist/bin/next-dev:63:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
error Command failed with exit code 1.
</code></pre></div>


<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>


<h2 dir="auto">Current Behavior</h2>


<h2 dir="auto">Steps to Reproduce (for bugs)</h2>


<ol dir="auto">
<li>Was on next 4</li>
<li>Upgrade to next 5</li>
<li>Error</li>
<li></li>
</ol>
<h2 dir="auto">Context</h2>


<p dir="auto">Followed this guide: <a href="https://github.com/zeit/next.js/blob/canary/examples/with-polyfills/next.config.js">https://github.com/zeit/next.js/blob/canary/examples/with-polyfills/next.config.js</a></p>
<p dir="auto">My next.config.js:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="// https://github.com/zeit/next.js/blob/master/examples/with-global-stylesheet

const path = require('path');
const glob = require('glob');

module.exports = {
  webpack: (config, { dev }) =&gt; {
    const originalEntry = config.entry
    config.entry = async () =&gt; {
      const entries = await originalEntry()

      if (entries['main.js']) {
        entries['main.js'].unshift('./client/polyfills.js')
      }

      return entries
    }

    // Set project root path as part of the resoler
    config.resolve = {
      modules: [
        ...config.resolve.modules,
        path.resolve('./')
      ]
    }

    // Original Issue:
    // https://github.com/zeit/next.js/issues/1877#issuecomment-299396974
    if (config.resolve.alias) {
      delete config.resolve.alias['react'];
      delete config.resolve.alias['react-dom'];
    }

    // TODO: Remove this once nextjs issue has been resolved: https://github.com/zeit/next.js/issues/1582
    config.plugins = config.plugins.filter(plugin =&gt; {
      if (plugin.constructor.name === 'UglifyJsPlugin') {
        return false;
      } else {
        return true;
      }
    });

    config.module.rules.push(
      // es6 transpilation in node_modules for object.assign
      {
        test: /\.(js|jsx)/,
        loader: 'babel-loader',
        exclude(file) {
          return file.startsWith(__dirname + '/node_modules/subscriptions-transport-ws') ? false : true;
        }
      },

      // yaml
      {
        test: /\.yaml$/,
        use: [
          {
            loader: 'emit-file-loader',
            options: {
              name: 'dist/[path][name].[ext]'
            }
          },
          'json-loader',
          'yaml-loader'
        ]
      },

      // css|scss
      {
        test: /\.(css|scss)/,
        loader: 'emit-file-loader',
        options: {
          name: 'dist/[path][name].[ext]'
        }
      },

      {
        test: /\.css$/,
        use: ['babel-loader', 'raw-loader', 'postcss-loader']
      },

      {
        test: /\.s(a|c)ss$/,
        use: ['babel-loader', 'raw-loader', 'postcss-loader',
          { loader: 'sass-loader',
            options: {
              includePaths: ['styles', 'node_modules']
              .map(d =&gt; path.join(__dirname, d))
              .map(g =&gt; glob.sync(g))
              .reduce((a, c) =&gt; a.concat(c), [])
            }
          }
        ]
      },

      {
        test: /\.(graphql|gql)$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'emit-file-loader',
            options: {
              name: 'dist/[path][name].[ext]'
            }
          },
          'babel-loader',
          'graphql-tag/loader'
        ]
      }
    );

    return config;
  }
};
"><pre class="notranslate"><code class="notranslate">// https://github.com/zeit/next.js/blob/master/examples/with-global-stylesheet

const path = require('path');
const glob = require('glob');

module.exports = {
  webpack: (config, { dev }) =&gt; {
    const originalEntry = config.entry
    config.entry = async () =&gt; {
      const entries = await originalEntry()

      if (entries['main.js']) {
        entries['main.js'].unshift('./client/polyfills.js')
      }

      return entries
    }

    // Set project root path as part of the resoler
    config.resolve = {
      modules: [
        ...config.resolve.modules,
        path.resolve('./')
      ]
    }

    // Original Issue:
    // https://github.com/zeit/next.js/issues/1877#issuecomment-299396974
    if (config.resolve.alias) {
      delete config.resolve.alias['react'];
      delete config.resolve.alias['react-dom'];
    }

    // TODO: Remove this once nextjs issue has been resolved: https://github.com/zeit/next.js/issues/1582
    config.plugins = config.plugins.filter(plugin =&gt; {
      if (plugin.constructor.name === 'UglifyJsPlugin') {
        return false;
      } else {
        return true;
      }
    });

    config.module.rules.push(
      // es6 transpilation in node_modules for object.assign
      {
        test: /\.(js|jsx)/,
        loader: 'babel-loader',
        exclude(file) {
          return file.startsWith(__dirname + '/node_modules/subscriptions-transport-ws') ? false : true;
        }
      },

      // yaml
      {
        test: /\.yaml$/,
        use: [
          {
            loader: 'emit-file-loader',
            options: {
              name: 'dist/[path][name].[ext]'
            }
          },
          'json-loader',
          'yaml-loader'
        ]
      },

      // css|scss
      {
        test: /\.(css|scss)/,
        loader: 'emit-file-loader',
        options: {
          name: 'dist/[path][name].[ext]'
        }
      },

      {
        test: /\.css$/,
        use: ['babel-loader', 'raw-loader', 'postcss-loader']
      },

      {
        test: /\.s(a|c)ss$/,
        use: ['babel-loader', 'raw-loader', 'postcss-loader',
          { loader: 'sass-loader',
            options: {
              includePaths: ['styles', 'node_modules']
              .map(d =&gt; path.join(__dirname, d))
              .map(g =&gt; glob.sync(g))
              .reduce((a, c) =&gt; a.concat(c), [])
            }
          }
        ]
      },

      {
        test: /\.(graphql|gql)$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'emit-file-loader',
            options: {
              name: 'dist/[path][name].[ext]'
            }
          },
          'babel-loader',
          'graphql-tag/loader'
        ]
      }
    );

    return config;
  }
};

</code></pre></div>
<h2 dir="auto">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>5.0.0</td>
</tr>
<tr>
<td>node</td>
<td>6.9.1</td>
</tr>
<tr>
<td>OS</td>
<td>OSX 10.13.2</td>
</tr>
<tr>
<td>browser</td>
<td>chrome  beta 65.0.3325.51</td>
</tr>
<tr>
<td>etc</td>
<td></td>
</tr>
</tbody>
</table>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>


<p dir="auto">The on-demand-entries-ping should include the current cookies in the request.</p>
<h2 dir="auto">Current Behavior</h2>


<p dir="auto">The on-demand-entries-ping does not include the current cookies in the request.</p>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>


<p dir="auto">If required, I can build an reproduction sample, but I think its obvious.</p>
<h2 dir="auto">Context</h2>


<p dir="auto">I am running a nginx as proxy splitting the request between a website served with next, and multiple microservices. All running in docker. For development I am running the website with next in dev mode within the same docker context so that the api request are handled the same way as in prod, but on localhost. The nginx is also validating the session cookies against an authentication services and exchange them for an access_token if the request is forwarded to one of the backend services. The proxy is also blocking the access to the next app if there is no token.<br>
Since the on-demand-entries-ping does not include the cookies, the request is blocked. As a workaround I could allow all <code class="notranslate">_next/...</code> requests with out cookies, but I think that there is no reason why the on-demand-entries-ping should not include the credentials.</p>
<h2 dir="auto">Solution</h2>
<p dir="auto">Add <code class="notranslate">{ credentials: 'same-origin' }</code> as parameter to the fetch requests, here: <a href="https://github.com/zeit/next.js/blob/v3-beta/client/on-demand-entries-client.js#L14">https://github.com/zeit/next.js/blob/v3-beta/client/on-demand-entries-client.js#L14</a> and here: <a href="https://github.com/zeit/next.js/blob/v3-beta/client/on-demand-entries-client.js#L19">https://github.com/zeit/next.js/blob/v3-beta/client/on-demand-entries-client.js#L19</a>.</p>
<p dir="auto">If this is an appropriate solution and you have no concerns I can send an PR, asap.</p>
<h2 dir="auto">Your Environment</h2>

<ul dir="auto">
<li>Next.js version: 3.0.1-beta.8</li>
<li>Environment name and version (e.g. Chrome 39, Node.js 5.4): node:8-alpine</li>
<li>Operating System (Linux, maxOS, Windows): docker on Linux</li>
</ul>