angular-http-server icon indicating copy to clipboard operation
angular-http-server copied to clipboard

Need possibility to allow returning index.html per route instead of sending the root one

Open BlindDespair opened this issue 5 years ago • 2 comments

Hello, thank you for the great tool, I found it really useful and sufficient to use for testing a multilanguage Scully app locally. But the problem is that the server obviously still treats it as a regular Angular app and returns the index.html from the root even for the other routes. It would be great if the server could send the index.html file from the directory of a route and only send the one from the root when such was not found (or based on a flag). I know Scully has its own serving solution but sadly it's not as advanced and cannot handle baseHref which is required in my case. My config so far looks like this:

const LOCALE_BASE_HREF = process.env.LOCALE_BASE_HREF || '/';
const BASE_HREF = process.env.BASE_HREF || '/';
const LOCALE = process.env.LOCALE || '';

const FULL_BASE_HREF = `${LOCALE_BASE_HREF.replace(/\/$/, '')}${BASE_HREF}`.replace(/^\//, '').replace(/\/$/, '');

module.exports = {
  p: 8080,
  baseHref: FULL_BASE_HREF,
  path: `dist/static/${BASE_HREF.replace(/\/$/, '')}/${LOCALE}`,
};

BlindDespair avatar Feb 14 '21 00:02 BlindDespair

Sounds like https://github.com/simonh1000/angular-http-server/pull/40 would be pretty useful for you?

simonh1000 avatar Feb 14 '21 07:02 simonh1000

@simonh1000 I checked that, but unfortunately it's not exactly what I need. That one is about having a different root file name, but in my case, imagine you need to open the app at /contact route(initially, not by simply navigating inside angular app). What it does now is that it returns index.html from the root, but I would need index.html from /contact directory in this case. Here is how the structure looks like: image

BlindDespair avatar Feb 14 '21 16:02 BlindDespair