【问题标题】:Spring Security and Grails - customizing URLS for HerokuSpring Security 和 Grails - 为 Heroku 自定义 URL
【发布时间】:2019-02-27 21:41:35
【问题描述】:

我正在使用以下插件: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 文件或插件配置造成的。如何解决?

Procfile 文件

web: cd build ; java $JAVA_OPTS -Xmx256m -Dgrails.env=prod -jar ../build/server/webapp-runner-*.jar --expand-war --port $PORT libs/*.war

【问题讨论】:

    标签: spring heroku grails google-oauth grails-plugin


    【解决方案1】:

    我只需要像这样将服务器 URL 添加到配置文件中:

    grails:
       serverURL: ${HOST_NAME}
    

    HOST_NAME 是一个环境变量。

    【讨论】:

      猜你喜欢
      • 2011-09-05
      • 2013-02-11
      • 2014-08-23
      • 1970-01-01
      • 2017-10-26
      • 2015-11-12
      • 2014-10-06
      • 1970-01-01
      • 2016-04-25
      相关资源
      最近更新 更多