Git Product home page Git Product logo

Comments (5)

CareyWang avatar CareyWang commented on June 26, 2024

项目使用 Golang 开发,打包生成的可执行文件可直接运行,无需使用 php。

没有使用过宝塔,建议服务器上看看redis-cli -h 127.0.0.1 -p 6379是不是能正常连接,或者按照 README 中重新安装 Redis。后续版本将加入 Redis host port 自定义参数与 docker-compose 部署支持。

跨域问题的话,我线上使用nginx配置反向代理,前端请求没有问题。

server {
    server_name example.com;

    location / {
        add_header 'Access-Control-Allow-Origin' '*';
        proxy_pass http://127.0.0.1:8002/;
    }
}

from myurls.

MFYDev avatar MFYDev commented on June 26, 2024

很奇怪,我这边还是不行,我的配置是这样的

首先短链接使用 https://link.mfy.cool 作为域名

然后后端输入 ./myurls.service -domain https://link.mfy.cool -port 8001 使用8001端口

然后在宝塔的反向代理里面 反向代理http://link.mfy.cool:8001 -> http://link.mfy.cool

SSL证书已申请

然后在反向代理配置里面加入 add_header 'Access-Control-Allow-Origin' '*';

最后宝塔的反向代理配置如下:

#PROXY-START/
location /
{
    proxy_pass http://link.mfy.cool:8001;
    proxy_set_header Host link.mfy.cool;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    
    add_header 'Access-Control-Allow-Origin' '*';
}

#PROXY-END/

前端的shortUrlbackend配置为 https://link.mfy.cool

最后使用的时候发现还是报错跨域缺少Access-Control-Allow-Origin

我人傻了。。。完全不知道错在哪里,请大佬指教一下,万分感谢了!

from myurls.

MFYDev avatar MFYDev commented on June 26, 2024

捕获
Redis正常运行,但是短链接后端就是这样

from myurls.

MFYDev avatar MFYDev commented on June 26, 2024

捕获
前端一直这样报错,域名解析是正常的

from myurls.

CareyWang avatar CareyWang commented on June 26, 2024

如果是配合sub-web使用,由于修改了请求方式,前端需要更新到最新。

image

from myurls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.