spring - Spring Security 和 Grails - 为 Heroku 自定义 URL
问题描述
我正在使用以下插件:https ://github.com/MatrixCrawler/grails-spring-security-oauth2
我在我的 application.yml 中以这种方式配置它:
grails:
plugin:
springsecurity:
oauth2:
active: true
domainClass: 'myapp.OAuthID'
providers:
google:
api_key: '...'
api_secret: '...'
它在 localhost 中运行良好,但是当我在 Heroku 中部署我的项目时,使用 Google 登录的按钮在 localhost 环境中返回一个回调。为什么?我不知道。
我会在浏览器中看到 Google 帐户,但是当我点击任何帐户时,服务器会重定向到http://localhost:8080/ ...
我认为这个问题是由于 Procfile 文件或插件配置造成的。如何解决这个问题?
过程文件
web: cd build ; java $JAVA_OPTS -Xmx256m -Dgrails.env=prod -jar ../build/server/webapp-runner-*.jar --expand-war --port $PORT libs/*.war
解决方案
我只需要将服务器 URL 添加到配置文件中,如下所示:
grails:
serverURL: ${HOST_NAME}
HOST_NAME 是一个环境变量。
推荐阅读
- python - Robotframework.request - 如何使用内容“multipart/form-data”发出 POST 请求
- c# - 从 PostMan 调用 asp.net core web api
- java - 我需要创建新课程吗?
- python - 字典分解并创建具有相同值的新字典
- c++ - 如何获取图标气球提示而不是通知幻灯片
- python - 提取大于其他列的所有值的列值 | 蟒蛇熊猫
- python - 如何从 Google Colab 的张量板上获取直方图
- amazon-web-services - AWS SNS 服务发送消息失败
- google-cloud-platform - 使用 GCP 网络端点组进行容器原生负载平衡的不健康后端
- python - Python Tkinter - 如何将一个类中的小部件放到另一个类的窗口中