0

I am using browser sync and a web api C# 2.0, when I call a method to login it returns in the response headers set-cookie, but the method does not set cookie in the browser.

browserSync.init({
    notify: false,
    cors: true,
    port: 6543,
    server: {
        baseDir: config.dir.src,
        routes: {
            "/bower_components": "bower_components"
        },
        middleware: [function(req, res, next) {
            next();
        }]
    }
});

Edit

Login returns cookie: enter image description here

Cookie browser: enter image description here

Max Ferreira
  • 679
  • 1
  • 5
  • 21
  • is request being made cross origin .. different port , subdomain or domain? – charlietfl Apr 14 '17 at 00:19
  • no, i am on localhost – Max Ferreira Apr 14 '17 at 00:20
  • and webapi is exact same as page? Tell us more about login request and how you determine cookie not set – charlietfl Apr 14 '17 at 00:22
  • Whenever I try to login, it works fine, and the cookie is sent back from the server. However, the next call to the api returns me an unauthorized error. When I was trying to find out what was going on, I noticed that the cookies are not set in my browser storage. I tried the same using postman and it worked fine aswell. – Max Ferreira Apr 14 '17 at 00:28
  • doubt it has anything to do with browserSync but does it work if you disable browserSync? – charlietfl Apr 14 '17 at 00:31
  • using iis it works – Max Ferreira Apr 14 '17 at 00:34
  • that's not very informative .... no difference in page origin? – charlietfl Apr 14 '17 at 00:36
  • Even when I manually set the cookie, I still getting the same unauthorized response... there is no difference. Seems as if the get request i'm sending can't read the cookie from my browser. – Max Ferreira Apr 14 '17 at 00:40
  • That response has CORS headers which makes me think request is not to same origin as page is on and you would need to set `withCredentials` in request – charlietfl Apr 14 '17 at 00:42

0 Answers0