OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why do I get a 403 error when requesting the WordPress API from a Laravel application hosted on Azure App Service?

  • Thread starter Thread starter Dioni Sanchez
  • Start date Start date
D

Dioni Sanchez

Guest
I have a Laravel application hosted on Azure App Service. When my Laravel app tries to fetch data from the WordPress API, it receives a 403 Forbidden error. Here are some key details:

WordPress API Accessibility:

  • The WordPress API endpoint is publicly accessible. I can access it directly from a browser and get a JSON response with posts.
  • The API works without issues when I host my Laravel app on a different hosting provider (not Azure).

Issue Specifics:

  • The issue only occurs when the Laravel app is hosted on Azure App Service. From Azure, the request to the WordPress API returns a 403 Forbidden error.
  • No authentication or IP restrictions are required for the WordPress API since it is publicly accessible.

Troubleshooting Steps Taken:

  • Confirmed that the API works from other hosting environments, local environment, browser requests.
  • Checked that there are no CORS issues as the endpoint is publicly accessible from any source.
  • Ensured that the Laravel app on Azure is configured correctly in terms of network and security settings.

Additional Details: Laravel Version: 10 WordPress Version: 6.5.5 Azure App Service Configuration: Basic setup without custom security rules. Just set my Wordpress site in CORS config.

Code in laravel:

Code:
public function getNews()
{
    $response = Http::get('https://blog.MY-DOMAIN.com/wp-json/wp/v2/posts', [
        'per_page' => 3,
        '_embed' => true
    ]);

    return $response->json();
}
<p>I have a Laravel application hosted on Azure App Service. When my Laravel app tries to fetch data from the WordPress API, it receives a 403 Forbidden error. Here are some key details:</p>
<p>WordPress API Accessibility:</p>
<ul>
<li>The WordPress API endpoint is publicly accessible. I can access it directly from a browser and get a JSON response with posts.</li>
<li>The API works without issues when I host my Laravel app on a different hosting provider (not Azure).</li>
</ul>
<p>Issue Specifics:</p>
<ul>
<li>The issue only occurs when the Laravel app is hosted on Azure App Service. From Azure, the request to the WordPress API returns a 403 Forbidden error.</li>
<li>No authentication or IP restrictions are required for the WordPress API since it is publicly accessible.</li>
</ul>
<p>Troubleshooting Steps Taken:</p>
<ul>
<li>Confirmed that the API works from other hosting environments, local environment, browser requests.</li>
<li>Checked that there are no CORS issues as the endpoint is publicly accessible from any source.</li>
<li>Ensured that the Laravel app on Azure is configured correctly in terms of network and security settings.</li>
</ul>
<p>Additional Details:
Laravel Version: 10
WordPress Version: 6.5.5
Azure App Service Configuration: Basic setup without custom security rules. Just set my Wordpress site in CORS config.</p>
<p>Code in laravel:</p>
<pre><code>public function getNews()
{
$response = Http::get('https://blog.my-domain.com/wp-json/wp/v2/posts', [
'per_page' => 3,
'_embed' => true
]);

return $response->json();
}
</code></pre>
Continue reading...
 

Latest posts

ن
Replies
0
Views
1
نعمان منذر محمود الجميلي
ن
Top