Answers.Body: <p>Forgot about this question!
  I've since solved it by using a different approach.</p>
  
  <p>Now I'm injecting the broser-sync script via its config, avoiding injection if the url is '/admin/', and redirecting to :8000 if '/admin/' is visited from :3000</p>
  
  <p>Here's my whole working browser-sync.js config file, for those few other souls searching for something similar: </p>
  
  <p>Note: I'm auto-injecting the webpack dev build with this config as well.</p>
  
  <pre><code>const sync = 3000
  const script = 'browser-sync-client.js'
  
  const php = 8000
  const webpack = 1337
  const adminPath = '/admin/'
  const address = require('ip').address()
  
  
  
  module.exports = {
      port: sync,
      proxy: {target: `${address}:${php}`},
  
      files: [
          'source/layout.twig',
          'source/pages/*.twig',
          'source/components/*.twig'
      ],
  
  
  
      ui: false,
      open: false,
      notify: false,
      ghostMode: false,
      socket: {clientPath: ''},
  
      logLevel: 'info',
      logPrefix: 'Browser-sync',
  
      watchEvents: ['change', 'add'],
  
  
  
  
  
      rewriteRules: [
          {match: /&lt;\/head&gt;/i, fn(request, result, match) {
              return `&lt;script src="http://${address}:${webpack}/build.js"&gt;&lt;/script&gt;` + match
          }}
      ],
  
      snippetOptions: {
          ignorePaths: adminPath + '*',
          rule: {
              match: /&lt;\/body&gt;/i,
              fn(snippet, match) {
                  return `&lt;script src="http://${address}:${sync}/${script}"&gt;&lt;/script&gt;` + match
              }
          }
      },
  
      middleware: [function(request, result, next) {
          if (request.url.startsWith(adminPath)) {
              result.writeHead(301, {Location: `http://${address}:${php}${request.url}`})
              result.end()
          } else {
              next()
          }
      }]
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-14T11:37:06.717Z
Answers.LastActivityDate: 2017-08-14T11:37:06.717Z
Answers.UserDisplayName: Ole
Body: <p>I've stumbled upon a weird thing.</p>
  
  <p>When I run browsersync as <code>browser-sync start -p localhost:8000</code> and try to log into Craft's admin at <code>localhost:3000/admin</code> I get the message "An unknown error occurred."</p>
  
  <p>If I enter the wrong password, nothing at all appears nor happens. </p>
  
  <p>This can be worked around by logging in once at <code>localhost:8000/admin</code>, and then accessing the proxied version after... But I'd be sweet if I could login through the proxied version :)</p>
  
  <p>Any suggestions on how this can be resolved?</p>
  
  <p>Here's the log generated once I've deleted all the contents of the logs and then press the login button: <a href="http://pastebin.com/3LjbQLj0" rel="nofollow noreferrer">http://pastebin.com/3LjbQLj0</a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-20T20:31:15.247Z
Comments.Text: I've tried to inspect the network tab to check if there's anything useful there: http://i.imgur.com/iM8VgZi.png
  
  Seems like it tries to push me to the dashboard...
Comments.UserDisplayName: Ole
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-20T20:35:14.037Z
Comments.Text: There's no response on the login POST either, it's all empty - not the usual JSON "success:true, returnUrl: ..."
Comments.UserDisplayName: Ole
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-09T22:08:38.930Z
Comments.Text: Instead of using localhost:port, can you try using a dedicated vhost maybe?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-14T11:38:20.810Z
Comments.Text: Solved it with a different approach! Thanks for the suggestion though - answered my own question now :)
Comments.UserDisplayName: Ole
Tags: <admin><login><cookies>
Title: "An unknown error occurred." appears when I try to log into Craft's admin using browsersync's proxy mode
ThreadText: # "An unknown error occurred." appears when I try to log into Craft's admin using browsersync's proxy mode
  
  (Asked by: username_0 on 2017-01-20)
  
  I've stumbled upon a weird thing.
  
  When I run browsersync as `browser-sync start -p localhost:8000` and try to log into Craft's admin at `localhost:3000/admin` I get the message "An unknown error occurred."
  
  If I enter the wrong password, nothing at all appears nor happens.
  
  This can be worked around by logging in once at `localhost:8000/admin`, and then accessing the proxied version after... But I'd be sweet if I could login through the proxied version :)
  
  Any suggestions on how this can be resolved?
  
  Here's the log generated once I've deleted all the contents of the logs and then press the login button: <http://pastebin.com/3LjbQLj0>
  
  **Tags:** admin, login, cookies
  
  > **Comments:**
  > **username_0**: I've tried to inspect the network tab to check if there's anything useful there: http://i.imgur.com/iM8VgZi.png  Seems like it tries to push me to the dashboard...  
  > **username_0**: There's no response on the login POST either, it's all empty - not the usual JSON "success:true, returnUrl: ..."  
  > **username_1**: Instead of using localhost:port, can you try using a dedicated vhost maybe?  
  > **username_0**: Solved it with a different approach! Thanks for the suggestion though - answered my own question now :)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2017-08-14. Score: 1 | Accepted answer
  
  Forgot about this question!
  I've since solved it by using a different approach.
  
  Now I'm injecting the broser-sync script via its config, avoiding injection if the url is '/admin/', and redirecting to :8000 if '/admin/' is visited from :3000
  
  Here's my whole working browser-sync.js config file, for those few other souls searching for something similar:
  
  Note: I'm auto-injecting the webpack dev build with this config as well.
  
  ```
  const sync = 3000
  const script = 'browser-sync-client.js'
  
  const php = 8000
  const webpack = 1337
  const adminPath = '/admin/'
  const address = require('ip').address()
  
  module.exports = {
      port: sync,
      proxy: {target: `${address}:${php}`},
  
      files: [
          'source/layout.twig',
          'source/pages/*.twig',
          'source/components/*.twig'
      ],
  
      ui: false,
      open: false,
      notify: false,
      ghostMode: false,
      socket: {clientPath: ''},
  
      logLevel: 'info',
      logPrefix: 'Browser-sync',
  
      watchEvents: ['change', 'add'],
  
      rewriteRules: [
          {match: /<\/head>/i, fn(request, result, match) {
              return `<script src="http://${address}:${webpack}/build.js"></script>` + match
          }}
      ],
  
      snippetOptions: {
          ignorePaths: adminPath + '*',
          rule: {
              match: /<\/body>/i,
              fn(snippet, match) {
                  return `<script src="http://${address}:${sync}/${script}"></script>` + match
              }
          }
      },
  
      middleware: [function(request, result, next) {
          if (request.url.startsWith(adminPath)) {
              result.writeHead(301, {Location: `http://${address}:${php}${request.url}`})
              result.end()
          } else {
              next()
          }
      }]
  }
  
  ```
  
  
  ---
  
  