我是saleor.io的新手,它是电子商务应用程序和nginx的开源平台。这个沙龙有三个模块:
192.168.0.102/grapghql/)
仪表板上(Node,包含javascript,键入脚本文件,在192.168.0.102:70)
我正在nginx上运行这三个模块,当我尝试通过仪表板登录时,我得到了以下CORS错误:

这是我的nginx配置文件,用于saleor核心:
upstream django {
server unix:///home/umair/PythonDjangoProjects/GitSaleor/mysite.sock fail_timeout=9000; # for a file socket
# server 192.168.0.102:80; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name 192.168.0.102; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/umair/PythonDjangoProjects/GitSaleor/media; # your Django project's media files - amend as required
}
location /static {
alias /home/umair/PythonDjangoProjects/GitSaleor/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/umair/PythonDjangoProjects/GitSaleor/uwsgi_params; # the uwsgi_params file you installed}}
这是我的saleor仪表板的nginx配置文件:
server {
listen 70;
listen [::]:70;
root /var/www/html/dashboard;
index index.html;
server_name 192.168.0.102;
location / {
try_files $uri $uri/ /index.html?$args;
}
}我如何解决这个错误?我有没有漏掉任何配置上的东西。
发布于 2020-08-10 23:25:41
我觉得你应该试着
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}在你的推销员核心位置区内。
https://stackoverflow.com/questions/63334557
复制相似问题