STU-22: Add custom local domain support for WordPress sites - #994
Conversation
4f49875 to
57a013b
Compare
| try { | ||
| console.log( 'Attempting to start proxy server with elevated privileges' ); | ||
|
|
||
| if ( currentPlatform === 'win32' ) { |
There was a problem hiding this comment.
Apparently in Windows, we need to run the proxy with admin rights. The AI proposed using netsh to forward to a custom port. I need someone to help me test Windows.
fredrikekelund
left a comment
There was a problem hiding this comment.
This seems to work relatively well in my light testing, which is great 👍 Still, this is a big feature, and we will need to test it thoroughly before landing.
A couple of initial high-level thoughts:
- There are several visual issues in the
Add sitemodal right now. We should get some designer input from @matt-west or someone else on how to implement this. - Users should be able to edit the domain after a site is added. This is already a big PR, so we don't necessarily need to implement that here, but it should go into the same release as this feature.
| useCustomDomain, | ||
| setUseCustomDomain, | ||
| customDomain, | ||
| setCustomDomain, | ||
| customDomainError, |
There was a problem hiding this comment.
This is not the fault of this PR, but we should really move this state inside SiteForm and pass it back to the parent in the onSubmit handler. Too much prop drilling now with no clear benefit.
There was a problem hiding this comment.
Entirely agree, I noticed it too :)
| if ( domainRegex.test( hostsContent ) ) { | ||
| return; // Domain already exists | ||
| } |
There was a problem hiding this comment.
What do we do when this happens..? Display some kind of error in the app?
There was a problem hiding this comment.
To clarify, I was thinking of cases when the domain is pointing to a different IP. Edge case, perhaps, but it ties into other error handling questions like #994 (comment)
wojtekn
left a comment
There was a problem hiding this comment.
The basic happy path works fine on Mac. I left some comments related to small issues and different cases.
264b825 to
48a1f37
Compare
I don't see any other way other than checking the string or introducing a format/classes for errors. The latter is better but I think it warrants its own PR instead. |
|
@wojtekn What is the domain you're using to test the transliterated domains? In my testing these are rejected during validation at the moment (which could be a good way to start) |
Gotcha. I agree with all of that. Let's look into it separately 👍 |
It was Japanese with the "マイ WordPress サイト" site name auto-generated. I pulled changes, but I don't see an auto-generated domain for any language. |
I'm not seeing that at the moment but my guess is that it happens maybe because the apps is trying to generate a "preview" while the site is not ready yet. (just a guess). |
|
Thanks both of you for your valuable reviews. I think I've addressed all the points. Let me know if we're missing something. |
|
Works great now! Thanks for adding test for the domain generation.
I can't reproduce it now, too. |
fredrikekelund
left a comment
There was a problem hiding this comment.
Looking good, @youknowriad 👍 Thanks for addressing all those comments. Let's make sure we get a design review for this before landing, but the core functionality looks mostly solid to me now (I just need to understand the logic around internationalized domain names)
|
Thanks @youknowriad. A lot of users are going to love this feature! I tested this locally and it worked well, although starting the site after entering my system password was quite slow. What’s stopping us from creating a custom domain for every new site that’s created in Studio? Local takes that approach. I feel like the custom domain field should be directly under A few things I noticed testing this.
|
Local has a "router mode" that is applied globally that you can disable. Also switching it back and forth means all your existing sites would stop working for now. Personally I prefer the control site per site but we can always have it as a global mode later. The reason we don't do it automatically though is that it depends on admin rights and not all the users have these.
This was a result of a rebase, it's now fixed
This is addressed too
A potential follow-up indeed, but it's not that simple because it requires updating the WP database for existing sites.
Yes |
That looks like a regression unrelated to this PR. I've created https://github.com/Automattic/dotcom-forge/issues/10582 to track it. It still looks better with @youknowriad's latest changes – at least the local path and domain fields are consistently aligned now. |
|
Can I get an approval here? What do you think is left? |
fredrikekelund
left a comment
There was a problem hiding this comment.
I ran another round of tests on Mac and Windows – it's looking good and works as expected. I did however encounter one more error handling scenario that I think we should handle before landing this PR (EADDRINUSE errors on port 80).
I believe we should be good to land this PR after addressing that 👍
fredrikekelund
left a comment
There was a problem hiding this comment.
Nice work, @youknowriad! We should be good to land this now 👍
Let's add some additional rows to our smoke testing sheet for this feature, @wojtekn. That gives us another chance to catch potential errors before the next release.
I've added a test case for local domain. |

Related issues
Summary …
Implementation details
Test plan
Pre-merge Checklist
Important note This PR has been created for a huge part using AI. My main purpose with this PR was to learn both Studio's code base and learn AI while implementing a useful feature.