致力于提供有竞争力的软件解决方案和服务,德尚网络欢迎您!
技术/产品咨询
技术/产品咨询
    • - 微信扫一扫 -

      QQ:181814630

      电话:15116362044

DSO2O演示
DSMall演示
DS多平台演示
  • DSPlatform(多平台系统)演示地址及账号
    支持普通店铺,外卖店铺,上门家政,上门服务,视频教育等,Thinkphp8.0+uniapp+mysql+Vue3,拓展性强,商户可开多个不同类型店铺,
    演示角色 演示地址 账号 密码
    后台PC端 点击进入 test 123456
    商户PC端(可开多个店铺) 点击进入 seller 123456
    店铺管理PC端 点击进入 seller 123456
    手机端 点击进入 test 123456
    骑手端 点击进入 test 123456
    师傅端 点击进入 test 123456
    短视频 点击进入 test 123456
    DSPlatform(多平台系统)uniapp移动端二维码演示地址
    • 用户端

    • 机构端

DSMall 跨域设置

开发环境:


第一种方法:

    使用谷歌浏览器, 右键谷歌浏览器 -》属性-》目标。在目标 后面新增--disable-web-security --user-data-dir如下图:(注意空格)

    

    添加好了后 关闭浏览器 重新打开  如果出现下图则说明成功

    

第二种方法:

1.修改H5程序目录下public/config.js

将API_HOST的值改成API接口地址  如果你的程序是locallhost 则就是http://localhost/public/api    如果选择API接口为服务器地址则就是:https://dsmall.csdeshang.com/api

2.修改H5程序目录下vue.config.js

给module.exports新增一项:

    baseUrl: '/',
    devServer: {
        proxy: {
            '/api': {
                target: 【你的网址】,//例http://dsmall.csdeshang.com
                changeOrigin: true,
                ws: true,

            }
        }
    }

正式环境:

注:假设pc程序放在D:/WWW/git/DSMall目录


需要注意不要和原来的配置冲突,例如宝塔环境中有引用php的配置,将会和location ~ \.php(.*)$ {冲突,此时需要注释此引用语句,并复制此php配置内容,再加上跨域内容就行了


1.如果是nginx服务器

server {

        listen       80;

        server_name  www.dsmall.com ;

        root   "D:/WWW/git/DSMall/public";

        location / {

        if ($request_method = 'OPTIONS') {

                add_header 'Access-Control-Allow-Origin' 'http://h5.dsmall.com';

                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

                add_header 'Access-Control-Allow-Headers' 'X-DS-KEY,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

                add_header 'Access-Control-Allow-Credentials' 'true';

                add_header 'Access-Control-Max-Age' 1728000;

                add_header 'Content-Type' 'text/plain charset=UTF-8';

                add_header 'Content-Length' 0;

                return 204;

             }

             if ($request_method = 'POST') {

                add_header 'Access-Control-Allow-Origin' 'http://h5.dsmall.com';

                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

                add_header 'Access-Control-Allow-Headers' 'X-DS-KEY,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

                add_header 'Access-Control-Allow-Credentials' 'true';

             }

             if ($request_method = 'GET') {

                add_header 'Access-Control-Allow-Origin' 'http://h5.dsmall.com';

                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

                add_header 'Access-Control-Allow-Headers' 'X-DS-KEY,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

                add_header 'Access-Control-Allow-Credentials' 'true';

             }

            index  index.html index.htm index.php;

            if (!-e $request_filename){

            rewrite  ^(.*)$  /index.php?s=/$1  last;

          }

            #autoindex  on;

        }

        location ~ \.php(.*)$ {

        if ($request_method = 'OPTIONS') {

                add_header 'Access-Control-Allow-Origin' 'http://h5.dsmall.com';

                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

                add_header 'Access-Control-Allow-Headers' 'X-DS-KEY,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

                add_header 'Access-Control-Allow-Credentials' 'true';

                add_header 'Access-Control-Max-Age' 1728000;

                add_header 'Content-Type' 'text/plain charset=UTF-8';

                add_header 'Content-Length' 0;

                return 204;

             }

             if ($request_method = 'POST') {

                add_header 'Access-Control-Allow-Origin' 'http://h5.dsmall.com';

                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

                add_header 'Access-Control-Allow-Headers' 'X-DS-KEY,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

                add_header 'Access-Control-Allow-Credentials' 'true';

             }

             if ($request_method = 'GET') {

                add_header 'Access-Control-Allow-Origin' 'http://h5.dsmall.com';

                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

                add_header 'Access-Control-Allow-Headers' 'X-DS-KEY,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

                add_header 'Access-Control-Allow-Credentials' 'true';

             }

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            fastcgi_param  PATH_INFO  $fastcgi_path_info;

            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;

            include        fastcgi_params;

        }

}

2.如果是apache服务器



    DocumentRoot "D:\WWW\git\DSMall\public"

    ServerName www.dsmall.com

    ServerAlias 

    Header set Access-Control-Allow-Origin "http://h5.dsmall.com"

    Header add Access-Control-Allow-Methods "GET, POST, OPTIONS"

    Header add Access-Control-Allow-Headers "X-DS-KEY,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type"

    Header add Access-Control-Allow-Credentials "true"

 

      Options FollowSymLinks ExecCGI

      AllowOverride All

      Order allow,deny

      Allow from all

      Require all granted

 


3.如果是IIS服务器

在D:\WWW\git\DSMall\public下新增web.config