forge-sdk icon indicating copy to clipboard operation
forge-sdk copied to clipboard

Using `createSite` throws `The resource you are looking for could not be found.`

Open aaronbushnell opened this issue 2 months ago • 9 comments

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

  1. Setup a project with the Forge SDK
  2. Use the a createSite() function with the server ID and parameters you'd like to use
  3. Ensure $wait is set to true (the default behavior)
  4. Call the function and the error should appear

aaronbushnell avatar Oct 24 '25 19:10 aaronbushnell

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?

jamesburrow23 avatar Oct 24 '25 20:10 jamesburrow23

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.

mehrancodes avatar Oct 25 '25 11:10 mehrancodes

Facing the same issue

muhammadsaeedparacha avatar Oct 25 '25 14:10 muhammadsaeedparacha

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.

fawzanm avatar Oct 26 '25 15:10 fawzanm

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');
    }

}

fawzanm avatar Oct 26 '25 16:10 fawzanm

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.

mehrancodes avatar Oct 27 '25 08:10 mehrancodes

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 😕

aaronbushnell avatar Oct 27 '25 13:10 aaronbushnell

For what it's worth, my last attempt to use createSite a moment ago appears to work!

aaronbushnell avatar Oct 27 '25 20:10 aaronbushnell

@aaronbushnell I was able to deploy a demo site with the SDK today - all working smoothly! 💪

mehrancodes avatar Oct 28 '25 09:10 mehrancodes