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:
public function getNews()
{
$response = Http::get('https://blog.MY-DOMAIN.com/wp-json/wp/v2/posts', [
'per_page' => 3,
'_embed' => true
]);
return $response->json();
}
New contributor
Dioni Sanchez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.