0

I'm working on localhost and I'm trying to use browsersync. I want to point it to my root directory, which is http://localhost:8080/site/

What should I write here:

server: { baseDir: "" } 

I tried ./ but didn't work.

It keeps redirecting me to http://localhost:3000/​ and getting this message: Cannot GET /

Here is my whole code:

browserSync.init({ server: { baseDir: "" } }); 
8
  • Did you try setting a port property to 8080 or proxy property to localhost:8080 inside the object passed to the browserSync.init function? Commented Feb 3, 2017 at 20:44
  • I tried this, but not sure if this is the proper way to do it: ui: { port: 8080 } Commented Feb 3, 2017 at 20:49
  • That sets the port for browsersync's UI, which is supposed to be separate from the main port. By default, the UI is accessed at 8080 and browsersync looks at port 3000 for the projects, unless otherwise specified. You might want to keep that option and set the port value to 8081 to prevent conflicts. Commented Feb 3, 2017 at 20:54
  • It's the same if I set it to 8081 Commented Feb 3, 2017 at 20:59
  • Did you try setting the port or proxy properties as I mentioned? Commented Feb 3, 2017 at 21:36

1 Answer 1

1

Using baseDir won't work in combination with PHP (takes only a static site)

Try proxy instead like the others suggested, and set a port.

Here's the code snippet:

browserSync.init({ port: 8080, proxy: "http://localhost:8080/site/" }); 

Note that it's not under 'server' anymore, like the code in your question.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.