-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JHipster 8.1.0: Custom image won't display in production; logo/images don't display with custom context path #24744
Comments
Documentation about context-path is available at https://www.jhipster.tech/production/#custom-context-path. But this feature is not officially supported and there is no plan to officially support it. |
Please open a discussion for follow-ups and improvements. |
@mshima -- a couple of things:
--cheers-- |
@logicglobe frontend frameworks now requires context-path at build time. Since there is no common config for frontend and backend, they need to be configured separately. |
@mshima Couple of things have come to light:
[NB: The primeicons DO show up in development, but NOT in production.] It feels like the new JHipster is overly restrictive. Is this by design? All these things worked without issue in JHipster 7.9.3... (PS: I'm not sure why you closed this issue so quickly. The issue is more than about custom path. It's about images that don't display in production. These are real problems. By closing the issue, you restrict visibility, so no one else will contribute to the solution. Someone else may have encountered these issues, and resolved them...) |
The issue description is all about custom path, if you have an issue without custom path you should open a new issue. This issue is closed because is a recurring issue and we don’t officially support this feature, context path should be posted in discussions instead. You can open a new issue to officially support context path again, we already discussed a couple of years ago. |
@mshima Thanks again. I already well understand that custom context path will not be supported. Indeed, I will likely abandon my attempt at a custom context path for now, I shall take your advice, and open a new issue. Somehow, this thread became all about context path, and missed the key problem of images not rendering in production. I should have been more clear in defining the issue. -- cheers -- |
Overview of the issue
I have developed an application. Everything works GREAT in development, but I'm experiencing problems in production.
Ultimately, I need to deploy the application with a custom context path of
.../myapp/
. In other words, once deployed in production, the application would be reached with the following URL: http://xxx.xxx.xxx.xxx:8080/myapp/The application displays a custom image on the landing/home page which I have stored alongside the application navbar logo at the following location:
\src\main\webapp\content\images\myapp.jpg
Under JHipster 7.9.3 and earlier, the method to deploy was simple:
./src/main/webapp/index.html
--> Change<base href="/" />
line to<base href="/myapp/" />
./gradlew -Pprod clean bootJar
./build/libs/myapp-0.0.1.jar
to the servermyapp.jar
java -jar myapp.jar --server.servlet.context-path=/myapp
Current Environment
In JHipster 8.1.0, I am having problems. The basic application functionality appears to works (pages render with data fetched from the database), BUT images and logos are not showing on screen.
Under the following scenarios, I get the following results:
Scenario 0
Make NO changes, build (
./gradlew -Pprod clean bootJar
) and execute with:java -jar myapp.jar
Nav bar logo shows, but custom image doesn't show. Console error shows:
GET http://xxx.xxx.xxx.xxx:8080/myapp.7815297769ec24a8.jpg [HTTP/1.1 401 Unauthorized 23ms]
I can view the image directly in the browser if I type in the following URL:
http://xxx.xxx.xxx.xxx:8080/content/myapp.7815297769ec24a8.jpg
Likewise, I can view the logo directly in the browser with:
http://xxx.xxx.xxx.xxx:8080/content/images/logo-jhipster.png
Scenario 1
Follow the steps outlined above for JHipster 7.9.3, change
index.html
<base />
tag, build and execute with:java -jar myapp.jar --server.servlet.context-path=/myapp/
Nav bar logo AND custom images do not show. Console errors are:
NB: I can fetch the logo and image directly in the browser with the following URL:
http://xxx.xxx.xxx.xxx:8080/myapp/content/images/logo-jhipster.png
http://xxx.xxx.xxx.xxx:8080/myapp/content/myapp.7815297769ec24a8.jpg
Scenario 2
Change
index.html
<base />
tag as above, modifyangular.json
projects -> myapp -> architect -> build -> options -> baseHref : '/myapp/', then execute with:java -jar myapp.jar --server.servlet.context-path=/myapp/
Exactly the same outcome as scenario 1
Scenario 3
Change
index.html
<base />
tag as above, modifyangular.json
(as above), modifywebpack.custom.js
-> config.plugins.push( new webpack.DefinePlugin({ ... base: '/myapp/'}), then execute with:java -jar myapp.jar --server.servlet.context-path=/myapp/
Exactly the same outcome as scenario 1
At this point, I'm thrashing, and need to ask for help. (Any suggestions and pointers will be welcomed with gratitude.)
Motivation for or Use Case
Need to render logos and images in production, preferably with custom context path.
Reproduce the error
See above.
Related issues
Suggest a Fix
No idea.
JHipster Version(s)
JHipster 8.1.0
JHipster configuration
.yo-rc.json
Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryBrowsers and Operating System
The text was updated successfully, but these errors were encountered: