wordpressmacosmampmamp-procodekit

Codekit 3 - External Server Issue


I've been using codekit for ages now, and now I've been using the version 3 since it came out.

I really like this app, but there's something I never really understood and I decided to post it here (hoping to finally understand how this works and how to make it works like I want).

I have MAMP pro installed, with some hosts.

Let's say I have this list of hosts with (fake) document root:

localhost -> documents/site1/dist
test -> documents/sitetest/dist

and let's assume that test is a wordpress site having the site url set to http://test/ in the database.

In codekit, when I enable the browser refresh, the bottom options asks me to write down the address I would visit to see my website.

Now, if I navigate to http://test/ my WordPress website loads and I am able to see everything.

In codekit I then setup the browser refreshing options to be the following:

Then when I click on the green dot (server) to preview my website, I'm expecting codekit to navigate to http://test:5757 and to properly display my website. This, unfortunately, is not the case. When I click on the preview (or server, it doesn't really make any difference for me) codekit navigates to my mac IP and the website is either not loading or loading without any external resource.

I don't think the issue is in the way I load the resource in WordPress (i use enqueue sources properly, and the website without using codekit refresh function works, load and displays as meant to).

So far, I always switched my current project to use the localhost host (changing the document root in MAMP pro) and then telling codekit to use the localhost ip as external server, but now it's a bit more complex, as I have way more projects and I was hoping not to change back and forth the document root to use codekit built in refreshing feature.

Is it possible? am I missing something here?

I read all I was able to find as well as watched the videos on codekit, but this bit here is still a bit unknown to me and any help would be really appreciated.

Thanks

PS: No need to mention I am on a MAC, right? :)


Solution

  • I don't believe I actually managed to fix this.

    I'll leave the answer here in case somebody else is facing the same issue.

    The problem I had was that my website http://test/ was using a theme called test.

    Codekit, for refreshing the browser, uses a simple string search and replace in the URL, and so everything that looked like "test" in the url was replaced by the internal ip.

    Quick example:

    http://test/wp-content/themes/test/index.php

    became

    http://192.168.0.1:5757/wp-content/themes/192.168.0.1:5757/index.php

    and of course no file where loaded successfully, as the path was wrong.

    To fix this?

    Just change the MAMP pro address to something that won't be present in the URL (in my case, the MAMP pro host called test became dev.test and problem solved.