Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Lack of API support in angular universal v7? #674

@Mica4DEV

Description

@Mica4DEV

Hi,

I've tested the code on the official website https://angular.io/guide/universal but the part of handling backend API does not work at all.
In fact, all requests to API paths fails (404 even when they are really here) even if they are described in the server.ts file.
To prove that, I've copied server.ts and removed all angular rendering and called it server.dev.ts, with only API routes (handled by expressjs only and no angular renderer) and if the universal app call the external server.dev.ts (which listen to another port and accepts CORS requests) it works.

Is there something I miss or there is nothing to be done on the v7 universal angular apps for API calls (or everything "non angular")?
I've downloaded the example on https://angular.io/guide/universal and even if the code states that api calls could be handled // TODO: implement data requests securely app.get('/api/*', (req, res) => { res.status(404).send('data requests are not supported'); });
In fact even if we change 404 to 200 it won't work, angular do not take into account custom route to expressjs.

Has anyone successfully implemented custom API routes with the current version of angular (as described in https://angular.io/guide/universal) ?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions