Search code examples
angularnetlifynetlify-function

Can I stop the default angular redirect behavior for specific endpoints?


I have an Angular app and serverless backend with Netlify all under the same domain.

so:

https://domain-name.com/*

I have my API under the same domain:

https://domain-name.com/api/v1/*

Is there a way to stop Angular router behaviour that will auto-redirect you if the router cannot match any routes.

Similar to how the proxy config can do so for local development?

If this is not possible, is the following possible with the current behaviour of Angular router:

Can I have my Netlify serverless functions under a sub-domain? e.g. https://api.domain-name.com/api/v1/*

Thanks


Solution

  • In the meantime, my solution is to just have Netlify create 2 builds of my repo

    One under the domain: https://domain-name.com/*

    And another under domain: https://domain-name-api.com/*

    I then have 2 commands to build from for each one:

    ng build --prod for Angular and make for the backend

    Seems to work although doesn't seem like the most efficient method given that im now running to builds of the same repo