将ssl添加到我的react-app到我的heroku服务器

问题描述 投票:0回答:1

我正在尝试使用certbot将ssl添加到我的heroku服务器。但是,我发现的问题是我需要创建一个URL来验证我的域 - 这是问题,因为我似乎无法将我的服务器代码以及我的客户端代码添加到同一个heroku服务器(并获得它们都在我需要验证域的同时运行..)

reactjs express heroku create-react-app
1个回答
1
投票

试试这个:

开始certbot手册证书:sudo certbot certonly --manual

按照提示进行操作,直到您到达某个特定类似yourdomain.tld/.well-known/acme-challenge/longstring123的文件,不要按Enter键继续!记下它给你的URL和“文件”数据。

在你的server.js中,添加如下内容:

app.get('/.well-known/acme-challenge/your-long-url-string', function(req, res) {
  res.status(200);
  res.send('your-long-verification-file-data');
});

确保此Express路由处理程序位于用于React的处理程序之上。

© www.soinside.com 2019 - 2024. All rights reserved.