Angular redirect route to server file

Discussão em 'Angular' iniciado por UncleBob, Setembro 23, 2024.

  1. UncleBob

    UncleBob Guest

    We have an application, and it should be able to display its license file that is part of the build package. Normally, this would be simple enough: a relative link to /3rdpartylicenses.txt will resolve to the file on the server, if no other route is triggered first.

    This application, however, is intended for web publication and integration into other websites. So you'd specify the content you want to display right there in the first route variable, for example https://myapp/mycontent.

    For this purpose, there's a wildcard in the routing that redirects everything to a component that loads in the specified content:

    {path: ':token', component: FeedSelectorComponent}


    In other words, any relative URL that is not otherwise explicitly routed ends up here.

    So I need to explicitly route /thirdpartylicenses.txt to the file located on the server. Except I have no idea how to express that and can't find the use case in the documentation.

    I've tried redirecting to itself, but that seems to end up in the same place (interestingly enough does not cause a recursion, though):

    {path: '3rdpartylicenses.txt', redirectTo: '/3rdpartylicenses.txt'},


    Presumably there must be some way to express this redirect, but I can't find it.

    The file is in its default location when exported by angular during the build process, which is the root folder. This works perfectly fine on another application that we have, but that one doesn't have a wildcard in the routing...

    Continue reading...

Compartilhe esta Página