Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails 3.0 static html in run-app

similar questions have been asked before, regarding grails 2(.3, .4). I find it strange that i could not find a way to do this, as it seems a standard use-case to me.

I simply want to serve html-pages, including their linked .css and .js (angular and jquery content) when i run grails run-app.

I want to check if my http-calls are handeled correctly on both sides - without needing to deploy a .war and configuring a database.

afaik grails run-app simply starts a jetty/tomcat - both of which can obviously serve .html pages. What do i have to do to make the grails development-tooling deploy my files?

I need to make http-requests, so using a different Server would violate JS-SOP, while deploying the .war would greatly slow down the development process

I've so far only found clunky jsonp, proxy, .war deployment solutions, or solutions for grails 2.x

I tried placing the files literally everywhere in the projects' structure (/src/main, /src/main/resources, /src/main/public, the assets folder and its subfolders, created web-app directories in every subdirectory, the Init, domain, conf directories - you name it)

like image 212
billdoor Avatar asked Jul 14 '15 09:07

billdoor


Video Answer


1 Answers

Add the index.html to src/main/resources/public

Then add this to UrlMappings.groovy:

"/"(redirect:"/index.html")


For grails >= 3.0.12

Location of static resources

In order to resolve an issue around how POST requests are treated for REST applications on non-existent resources, static resources located in src/main/resources/public are now resolved under the /static/** URI by default, instead of the base URI /**. If you wish to restore the previous behaviour add the following configuration:

grails.resources.pattern = '/**'

https://github.com/grails/grails-core/releases/tag/v3.0.12

like image 124
Graeme Rocher Avatar answered Oct 21 '22 10:10

Graeme Rocher