I am using Jhipster(Angular + Springboot) Application for my existing project.
I managed to create a controller(app.resource) manually apart from the ones already generated by jhiptser(using .jh file) for achieving a file download functionality.
So, when we start the server we usually initiate two servers i.e gradlew
and npm start
. The second runs on port 9000 which eventually supports hot reload functionality.(front-end development)
So the problem is, I am able to access those endpoints from the server running on standard 8000 port. However, from the port which is a proxy(9000), the method is returning 404.
I tried to clean build the application several times.
NOTE: The @RequestMapping
value on the new controller is different then those present already.
Does this have to do something with spring security?
Thanks in advance.
Here is the previous controller:
@RestController
@RequestMapping("/api")
public class FGAppDiagramResource {
@GetMapping(value = "/fg-app-diagram-downloadFile")
public void getImage(String fileName,String folderName, HttpServletResponse
response){
// Some Code
}
}
Here is my New controller:
@RestController
@RequestMapping("/fileDownload")
public class DownloadFileController {
private final Logger log =
LoggerFactory.getLogger(DownloadFileController.class);
public DownloadFileController() {
super();
}
@Autowired
private ApplicationProperties applicationProperties;
@GetMapping(value = "/fg-app-diagram-downloadFile/{fileName}/{folderName}")
public void getImage(@PathVariable String fileName,@PathVariable String folderName, HttpServletResponse response) {
// Some Code
}
}
Your new controller does not use /api
so you must add your endpoint URL /fileDownload
to proxy configuration of webpack dev server in webpack/webpack.dev.js
proxy: [{
context: [
/* jhipster-needle-add-entity-to-webpack - JHipster will add entity api paths here */
'/api',
'/fileDownload',
You may want to use /api/fileDownload
to avoid changing proxy configuration and also because /api
is useful for many other aspects like security and also using HTML5 URL routing strategy in Angular to get rid of #
in client routes (see https://github.com/jhipster/generator-jhipster/pull/9098).
/api
and /management
are namespaces to avoid route conflicts, so it is usually wise to use them for your new endpoints.