Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bhojkamal's avatar

Access to XMLHttpRequest at from origin has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

Hello, I got this error Access to XMLHttpRequest at 'https://api.example.com/forgot/password' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

I am using laravel 9 at backend for api, and next.js at the frontend and sendinblue smtp mail services to send email, nginx server, ubuntu 22.

It works perfectly if I don't need to send email. But I need to send email, e.g. to reset password, I got above error. But this also work if use localhost:3000 in local development and email also sent with reset link.

But If i use vps server on live, it throws above error only if I need to send transaction email like forget password.

It works if I use mailtrap smtp details on live too.

I've searched on google, looked in sendinblue documentation, laravel example with sendinblue smtp mail too. But I could not fixed it.

in my .env of laravel, I have this

MAIL_MAILER=smtp
MAIL_HOST=smtp-relay.sendinblue.com
MAIL_PORT=587 # or 465
[email protected]
MAIL_PASSWORD=xxxxxxx #master password from sendinblue smtp
MAIL_ENCRYPTION=tls

in my config/cors.php

'paths' => ['*', 'sanctum/csrf-cookie', 'api.*'],
    'allowed_methods' => ['*'],
    'allowed_origins' => ['*'],
    'allowed_origins_patterns' => [],
    'allowed_headers' => ['*'],
    'exposed_headers' => [],
    'max_age' => 0,
    'supports_credentials' => true,

I will appreciate if you could give me a solution for this issue / error.

0 likes
2 replies
bhojkamal's avatar

@jlrdw thank you.

I think, my error is from linode - cloud server provider, I asked to activate smtp port and it worked now.

Please or to participate in this conversation.