0

I have a grails project and right now the URL to connect to it is this awful string like so:

 http://mynodename.foobar.com:8080/MyAppName-0.1/

I would like it to be:

 http://myappname.foobar.com/

I assume this is done in UrlMappings but I can't figure out how to do it and can't seem to find any info on it.

Another question, when I bookmarkthe URL I'd like it to default to 'MyAppName', where is that done?

Any help appreciated greatly!

Sulteric
  • 505
  • 6
  • 16
  • 5
    Possible duplicate of [How to remove app name and port from url in grails?](https://stackoverflow.com/questions/5989910/how-to-remove-app-name-and-port-from-url-in-grails) – Ivar Jun 05 '19 at 11:36
  • that shows how to remove the port number and app name but how do i form the url so that the appname is part of it, like http://MyAppName.foobar.com? – Sulteric Jun 05 '19 at 15:33
  • That is not in the scope of Grails. To achieve that you need to create a subdomain and let that point to your application as you would do for any other domain. – Ivar Jun 05 '19 at 18:00
  • Grails 3+ this is normally not neccessary (and settable in `grails-app/conf/application.yml`, see http://docs.grails.org/latest/guide/gettingStarted.html#aHelloWorldExample) In Grails 2 it _is_ also possible (see https://stackoverflow.com/questions/5989910/how-to-remove-app-name-and-port-from-url-in-grails) – Stefan Rother-Stübs Jun 06 '19 at 11:23

2 Answers2

1

If you want your app to run locally and respond at http://myappname.foobar.com/ then you will want to run the app on port 80 (the default is 8080) and you will need to configure your environment so myappname.foobar.com resolves to your local machine. Depending on your environment you might have to do that via DNS but more likely what you want is to edit your local HOST config to support that. That doesn't have anything to do with Grails and the specifics of how to do that depend on what operating system you are using.

More common is that folks use the default localhost:8080 in their development environment because there really aren't many good reasons to not do that in most cases, but you don't have to.

EDIT

Note that the URL you use in your development environment doesn't have to have anything at all to do with your deployment environment. For example, http://start.grails.org is a Grails app. You access it at start.grails.org. When I run that app locally for development, I access it at localhost:8080.

I hope that makes sense.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47
0
production:
    server:
        port: 5000
    grails:
        serverURL: 'https://www.domain.io'

This works form me on application.yml file