cancel
Showing results for 
Search instead for 
Did you mean: 

Session / Cookie issue on browser sync

Session / Cookie issue on browser sync

I'm having an issue where I can't do any session/cookie based actions on the frontend through browser sync's proxy, I'm assuming it has to do with the domain name (localhost:3000 vs mysite.dev) is there any way around this?

 

Thanks.

5 REPLIES 5

Re: Session / Cookie issue on browser sync

I don't have any solution yet, but using proxyReq and proxyRes methods you can intercept every request and made necessary changes, so probably there is a way to "fake" a real store.

 

https://browsersync.io/docs/options#option-proxy

Re: Session / Cookie issue on browser sync

Interesting, it's weird because it seems like this was 'fixed':

https://github.com/BrowserSync/browser-sync/issues/124

 

There are some workarounds apparently but it didn't work for me:

https://github.com/BrowserSync/browser-sync/issues/737

Re: Session / Cookie issue on browser sync

-

Re: Session / Cookie issue on browser sync

Hi there,
you could try my solution, it solved 

Failed to load resource: net::ERR_CONNECTION_REFUSED

problem, and enabled logging, adding to cart:

in browser-sync config:

 

{
"socket": {
"domain": "localhost:3000"
}
}

inside `yourtheme/Magento_Theme/templates/html/browsersync.phtml`, paste:

<script id="__bs_script__">//<![CDATA[
document.write("<script async src='http://localhost:3000/browser-sync/browser-sync-client.js?v=2.18.8'><\/script>");
//]]>
</script>

and extend `default_head_blocks.xml` with custom block pointing to the script above:

<referenceContainer name="before.body.end">
<block class="Magento\Framework\View\Element\Template" template="Magento_Theme::html/browsersync.phtml" name="browserSync" />
</referenceContainer>

after running gulp, and entering to your local dev, browserSync should connect to the site, which should work with all functionalities.

Best regards, Adrian.

Re: Session / Cookie issue on browser sync

@adyry Too hacky solution and you have to care to not push this code to production. 

 

I recently posted on Github a possible fix proposed by @iancassidyweb which should solve all issues on Frontools level.