Skip to content

Swatch selection gets 404 #31

@anhdao1703

Description

@anhdao1703

I've installed Magento 2.4.4-p6 with default settings. Whenever I try to change the product color on the Product Listing Page (PLP), it keeps loading and eventually shows a 404 error for the URL swatches/ajax/media/?product_id=1367&isAjax=true.
Screenshot 2024-05-01 at 2 30 40 PM
I suspect the issue lies within the Nginx configuration. Here's my current Nginx configuration:
`server {
listen 8080;
listen [::]:8080;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name dev-default.local;
{{root}}

location /static/ {
location ~ ^/static/version {
rewrite ^/static/(version\d*/)?(.)$ /static/$2 last;
}
location ~* .(ico|jpg|jpeg|png|gif|svg|js|json|css|swf|eot|ttf|otf|woff|woff2|html)$ {
add_header Access-Control-Allow-Origin "
";
expires max;
access_log off;
if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.)$ /static.php?resource=$2 last;
rewrite ^/static/(.
)$ /static.php?resource=$1 last;
}
}
}

location ~/media/ {
add_header Access-Control-Allow-Origin "*";
expires max;
try_files $uri $uri/ /get.php$is_args$args;
}

location /en/ {
location ~ ^/en/(static|media|errors)/ {
rewrite ^/en/(.*)$ /$1 last;
}
try_files $uri $uri/ /en/index.php$is_args$args;
}

try_files $uri $uri/ /index.php?$args;
index index.php index.html;

location ~ .php$ {
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#try_files $uri =404;
try_files $uri $uri/ /index.php?$args;
fastcgi_read_timeout 3600;
fastcgi_send_timeout 3600;
fastcgi_param HTTPS "on";
#fastcgi_param MAGE_RUN_CODE "store_code";
#fastcgi_param MAGE_RUN_TYPE "website";
{{php_fpm_listener}}
{{php_settings}}
}

location ~* ^.+.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|woff2|eot|mp4|ogg|ogv|webm|webp|zip|swf)$ {
add_header Access-Control-Allow-Origin "*";
expires max;
access_log off;
}

if (-f $request_filename) {
break;
}
}

server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
{{ssl_certificate_key}}
{{ssl_certificate}}
server_name dev-default.local;
{{root}}

{{nginx_access_log}}
{{nginx_error_log}}

if ($scheme != "https") {
#rewrite ^ https://$host$uri permanent;
}

{{basic_auth}}

location /media/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header Host $host;
proxy_set_header HTTPS "off";
proxy_pass http://127.0.0.1:8080;
proxy_hide_header Via;
proxy_hide_header Vary;
proxy_hide_header X-Server;
#proxy_hide_header X-Backend-Server;
proxy_max_temp_file_size 0;
proxy_connect_timeout 7200;
proxy_send_timeout 7200;
proxy_read_timeout 7200;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}

location / {
location ~ ^/static/version {
rewrite ^/static/(version\d*/)?(.)$ /static/$2 last;
}
location ~* .(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ {
add_header Access-Control-Allow-Origin "
";
expires max;
access_log off;
if (!-f $request_filename) {
proxy_pass http://127.0.0.1:6081;
#proxy_pass http://127.0.0.1:8080;
}
}
proxy_pass http://127.0.0.1:6081;
#proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header Via;
proxy_hide_header Vary;
proxy_hide_header X-Server;
proxy_hide_header X-Backend-Server;
proxy_hide_header X-Frame-Options;
proxy_redirect off;
proxy_max_temp_file_size 0;
proxy_connect_timeout 720;
proxy_send_timeout 720;
proxy_read_timeout 720;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}
}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions