frontend flutter works fine at domain. when I open console at browser I found these error.
[Error] Origin https://www.championmaung.com is not allowed by Access-Control-Allow-Origin. Status code: 404
[Error] XMLHttpRequest cannot load https://championmaung.com/api/login due to access control checks.
Failed to load resource: Origin https://www.championmaung.com is not allowed by Access-Control-Allow-Origin. Status code: 404
I am not sure the about configuration and laravel works correctly.
configuration file here
root@srv543846:/etc/nginx/sites-available# nano flutter
server {
listen 80;
listen [::]:80;
server_name championmaung.com www.championmaung.com;
root /var/www/html/web;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /index.html;
location ~ /. {
deny all;
}
}
root@srv543846:/etc/nginx/sites-available# nano laravel
server {
listen 80;
server_name championmaung.com www.championmaung.com; # Replace with your domain or IP
root /var/www/html/laravel_for_football/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Ensure the PHP version matches
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
-rw-rw-r– 1 root root 1217 Jun 22 15:15 default.conf
lrwxrwxrwx 1 root root 34 Jun 22 08:13 flutter -> /etc/nginx/sites-available/flutter
lrwxrwxrwx 1 root root 34 Jun 22 13:13 laravel -> /etc/nginx/sites-available/laravel
root@srv543846:/etc/nginx/sites-enabled# nano default.conf
server {
if ($host = www.championmaung.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = championmaung.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name championmaung.com www.championmaung.com api.championmaung.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name championmaung.com www.championmaung.com;
ssl_certificate /etc/letsencrypt/live/championmaung.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/championmaung.com/privkey.pem; # managed by Certbot
root /var/www/html/web;
index index.html;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /index.html;
location ~ /. {
deny all;
}
location /api {
alias /var/www/html/laravel_for_football/public;
try_files $uri $uri/ /index.php?$query_string;
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
}
thoin htoo aung is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.