alex35mil / sourcebuster-js

Track the sources of your traffic
https://alexfedoseev.github.io/sbjs
MIT License
412 stars 92 forks source link

Doesn't Work on Localhost #16

Closed Nicholas-Westby closed 6 years ago

Nicholas-Westby commented 7 years ago

I spent a few hours trying to figure out why this library didn't seem to be working, and why it wasn't creating the "sbjs" cookies. I figured out that it doesn't seem to like the localhost domain used by Visual Studio (e.g., "http://localhost:1234/"). Probably related to the way cookies work: https://stackoverflow.com/questions/1134290/cookies-on-localhost-with-explicit-domain

I have two options to recommend:

FYI, I'm using Chrome.

afrozek commented 6 years ago

TLDR; Edit etc/hosts file Use faketwitter.com:8080 > href link to > mydevapp.com:3000

I ran into a similar issue, the workaround for me was to modify your /etcs/hosts file and add any domain name for your localhost app.

ie. /etc/hosts add the following lines 127.0.0.1 mydevapp.com 127.0.0.1 faketwitter.com

say your app is running on port 3000 I made another test web server(nodejs) on port 8080, and served a webpage which had a link to my app running on port 3000.

But instead of using localhost, use faketwitter.com:8080 > href link to > mydevapp.com:3000

I've tested this and it works like a charm.

image

alex35mil commented 6 years ago

^ This. And I wouldn't call it workaround. Using valid domain name for development is a must for real-world apps imo.

Nicholas-Westby commented 6 years ago

Using valid domain name for development is a must for real-world apps imo.

I have built dozens of websites on localhost that disagree with you.

AndreiSoroka commented 5 years ago

@Nicholas-Westby I agree with you) @alexfedoseev I think https://github.com/alexfedoseev/sourcebuster-js/pull/19 and https://github.com/alexfedoseev/sourcebuster-js/pull/27 fix all problems with local development

AndreiSoroka commented 2 years ago

mr is opened 4 years...