Comments (7)
@Hoverbear Right now, if you're using yeoman server to launch this, the only way to have all your routes work and reloadable is to use the hash style href="/#/alt".
The angular generator leaves out $locationProvider.html5Mode(true); in the app.js file after configuring the routes. We can put this back in, but we would run into the issue you describe where you can navigate to the /alt link, but you can't reload it.
The problem is that the yeoman server doesn't have a default route which serves the index.html file. If that were the case, you could use the route /alt and serve the index file which would then load views/alt.html.
Theory is that the express server gets a request, if it's not a static file or api route, it should serve the index.html file. That way, you can load up any page in the app from a clean URL. The last line in my express servers is app.get("*", routes.index); It's a catch-all route when all static files and api routes have not matched.
from generator.
@jacobmumm Thanks for the info - I can confirm the same behaviour. I.e. routes load the Yeoman 404 page instead of the correct AngularJS route when using$locationProvider.html5Mode(true);
.
@btford I guess a solution would be to get the aJS generator to just create a 404 route in app.js, and point all unknown URL's towards index.html
?
from generator.
+1
from generator.
What is the status on this [image attached]? Any workaround for this livereload issue?
- yeoman server should either allow configuration options to be passed in, or at least allow easy configuration of the server.
- yeoman's server configuration (when using angular and html5Mode=true) should provide a catch all to serve up index.html all the time to allow the angular app to handle the routing inside the app.
In meantime, would love if someone could point towards a temporary workaround to get this to work. Modify yeomans server configuration in the internals somewhere?
from generator.
Here is the temporary WORKAROUND:
Yeoman LiveReload configuration tweak
This is a temporary hack until yeoman's server configuration supports an option to do something like this
pico /usr/local/lib/node_modules/yeoman/tasks/server.js
Ctrl +W, search for: function errorHandler
Paste the below block in between the following:
return function errorHandler(req, res, next) {
fs.readFile('app/index.html',function (err, data){
res.writeHead(200, {'Content-Type': 'text/html','Content-Length':data.length});
res.write(data);
res.end();
});
return;
// Figure out the requested path
Ctrl +O (that's the letter 'O') - to SAVE!
Now yeoman should play nice with LiveReload and change watching. No More 404 when LiveReload fires!!
from generator.
@NathanWalker your workaround doesn't work with beta3 (as yeoman is using grunt for server). Any idea how to do it with grunt?
from generator.
@patcito yeoman/generator-angular#132
from generator.
Related Issues (20)
- Minimist CVE HOT 1
- "Which type of client-side component to create?" is missing "Extension" HOT 1
- Introduce a flag to use config in proxymode HOT 1
- Is this project abandoned? HOT 1
- Dependent library tui-jsdoc-template has high severity vulnerabilities HOT 1
- Value from option defined in a composed generator is only available on generator triggered HOT 2
- "Invoke validation failed. User forbidden to perform action" when trigger "More details" button of message extension sample HOT 2
- Cannot Remove Default Add-In HOT 2
- [deps] Check for breaking changes in Dependabot's PRs HOT 1
- Can't install 6.0.1 using npm HOT 5
- Improve readability of fs.test.ts; correct TS problems in it.
- Migrate tests to vitest and add node 20 to ci
- Replace jsdoc with typescript based documentation generator
- Dependency Conflict on `mem-fs` for yeoman-generator 7.x HOT 9
- yeoman-generator should declare an ordinary dependency on 'mem-fs' HOT 3
- Documentation is out of date HOT 2
- yeoman-generator wants conflicting transitive dependencies on mem-fs HOT 3
- How to compose generators in our own ESM-based generator HOT 8
- different document HOT 1
- issue with spawnCommandSync and (linux) mount during generator run HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator.