Spring Security和Grails - 为Heroku定制URL

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

我使用以下插件: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个回答
0
投票

我只需要将服务器URL添加到配置文件中,如下所示:

grails:
   serverURL: ${HOST_NAME}

HOST_NAME是一个环境变量。

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