Using `createSite` throws `The resource you are looking for could not be found.`
Forge SDK Version
3.21.0
Laravel Version
11.28
PHP Version
8.3.26
Database Driver & Version
No response
Description
We're using Forge to provision a new site, but regardless of the server ID we use we get the following error:
Laravel\Forge\Exceptions\NotFoundException
The resource you are looking for could not be found.
at vendor/laravel/forge-sdk/src/MakesHttpRequests.php:112
108▕ throw new ForbiddenException((string) $response->getBody());
109▕ }
110▕
111▕ if ($response->getStatusCode() == 404) {
➜ 112▕ throw new NotFoundException;
113▕ }
114▕
115▕ if ($response->getStatusCode() == 400) {
116▕ throw new FailedActionException((string) $response->getBody());
+6 vendor frames
7 app/Data/Sandbox.php:45
Laravel\Forge\Forge::createSite("ID_HERE", ["example.com", "php", "php83", "/src/public", "DATABASE_HERE"])
8 app/Commands/CreateCommand.php:34
App\Data\Sandbox::createSite()
It looks like a POST request is sent to servers/OUR_SERVER_ID/sites, but a 404 is triggered when a GET request is made to servers/OUR_SERVER_ID/sites/THE_NEW_SITE_ID.
I can provision a site without issue in Forge directly. But it seems it isn't working through the API.
For what it's worth it was working yesterday if some date coordination helps here!
Steps To Reproduce
- Setup a project with the Forge SDK
- Use the a
createSite()function with the server ID and parameters you'd like to use - Ensure
$waitis set totrue(the default behavior) - Call the function and the error should appear
I'm also experiencing this exact issue. I can redeploy existing sites via the forge API but creating new sites for my server is throwing this same exception.
I suppose it could have to do with me using the legacy API but it was my understanding that it would still work until march of next year?
Same here when starting to create a site - findServer and findSite still work fine, but on the Forge dashboard I’m seeing this error:
“We were unable to add a site to your server.”
Looks like that’s where it’s failing.
Facing the same issue
Facing the same issue, I guess Forge is becoming a headache for running a business now. They have ZERO idea about what the customer actually wants, just doing fancy UI and shipping fast is the new goal now.
I wrote a custom script to get my app running. You can use this, the other stuff seems to be working. <?php
namespace App\Forge;
use Exception;
use Illuminate\Support\Facades\Http;
class ForgeService
{
public static function create_site(int $serverId, string $fqn)
{
$orgName = 'mohamed-org';
$siteConfig = [
'type' => 'php',
'domain_mode' => 'custom',
'name' => $fqn,
'web_directory' => '/',
'www_redirect_type' => 'none',
'allow_wildcard_subdomains' => false,
'is_isolated' => false,
'php_version' => 'php74',
'zero_downtime_deployments' => false,
'install_composer_dependencies' => false,
'push_to_deploy' => false,
];
$token = config('services.forge.new-token');
if (!$token) {
throw new Exception('Laravel Forge API token is not configured.');
}
$url = "https://forge.laravel.com/api/orgs/{$orgName}/servers/{$serverId}/sites";
$response = Http::withHeaders([
'Authorization' => "Bearer {$token}",
'Content-Type' => 'application/json',
])->post($url, $siteConfig);
if ($response->failed()) {
throw new Exception(
"Failed to create Forge site: " . $response->body(),
$response->status()
);
}
return $response->json('data');
}
}
Looks like the organization slug is now required for most POST API calls. I was able to create a site using the new API, but just realised I’ll need to update other endpoints too - like install git repository.
Good find, @mehrancodes! Right now I'm just using the Forge SDK functions as-is, but I might need to temporarily use the API for this call in the interim 😕
For what it's worth, my last attempt to use createSite a moment ago appears to work!
@aaronbushnell I was able to deploy a demo site with the SDK today - all working smoothly! 💪