Description / Feature proposal
Serving a web application with built-in router in 3 ways :
Later it could be interesting to handle the rendering on CDNs or to use also CDNs for loopback requests. The goal is to have a high performance delivery service for the user.
Current Behavior
Does not propose a default way to use a routed App such as Angular, React, Vuejs leading to 404 errors.
Expected Behavior
Some tries of mine
I will speak for Angular first even if I think VueJS and React should be really close in the use.
In loopback 3 there was a need to change the middleware and let the angular app handle routes, so if your web application was in a public folder you would need to serve index.html and redirect every routes to the index.html to let Angular deal with these routes.
Here is a post on how to do it : stackoverflow - configure loopback 3 to serve Angular 4+
Now get back to loopback 4.
I think the file to change to let the web app deal with routes is the sequence file : src/sequence.ts
If I serve the dist folder of a fresh Angular in the public folder I will have some 404 errors from Angular in browser console :
GET http://localhost:3000/runtime.js net::ERR_ABORTED 404 (Not Found)
5Refused to execute script from '<URL>' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:3000/runtime.js' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:3000/polyfills.js' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:3000/styles.js' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:3000/vendor.js' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
localhost/:1 Refused to execute script from 'http://localhost:3000/main.js' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
4localhost/:13 GET http://localhost:3000/polyfills.js net::ERR_ABORTED 404 (Not Found)
For now I am trying to play with the sequence.ts file to re-send http routes in browser to the angular app like in loopback 3, any help would be appreciated.
Regards.
Description / Feature proposal
Serving a web application with built-in router in 3 ways :
Later it could be interesting to handle the rendering on CDNs or to use also CDNs for loopback requests. The goal is to have a high performance delivery service for the user.
Current Behavior
Does not propose a default way to use a routed App such as Angular, React, Vuejs leading to 404 errors.
Expected Behavior
Some tries of mine
I will speak for Angular first even if I think VueJS and React should be really close in the use.
In loopback 3 there was a need to change the middleware and let the angular app handle routes, so if your web application was in a public folder you would need to serve index.html and redirect every routes to the index.html to let Angular deal with these routes.
Here is a post on how to do it : stackoverflow - configure loopback 3 to serve Angular 4+
Now get back to loopback 4.
I think the file to change to let the web app deal with routes is the sequence file :
src/sequence.tsIf I serve the dist folder of a fresh Angular in the public folder I will have some 404 errors from Angular in browser console :
For now I am trying to play with the sequence.ts file to re-send http routes in browser to the angular app like in loopback 3, any help would be appreciated.
Regards.