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

Lack of API support in angular universal v7? #674

Open
Mica4DEV opened this issue Mar 25, 2019 · 2 comments
Open

Lack of API support in angular universal v7? #674

Mica4DEV opened this issue Mar 25, 2019 · 2 comments

Comments

@Mica4DEV
Copy link

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

@Mica4DEV
Copy link
Author

I thought I found a solution but there's none for the development environment. All /api/ calls are catch by the dev engine and there's no possibility to fully use only one project as it was before (I was able to use universal on my project in angular 5), except by launching an express server with the express routes in here... :(

@Mica4DEV Mica4DEV reopened this Apr 18, 2019
@Jorgen-VikingGod
Copy link

Any progress here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants