Closed royipressburger closed 7 years ago
Regarding the CORS.. I have no experience with expressjs on typescript but this should be fine:
function allowCrossDomains(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", "Content-type,Accept,X-Custom-Header, Authorization");
res.header('Access-Control-Allow-Credentials', 'true');
if (req.method === "OPTIONS") {
return res.status(200).end();
}
next();
}
app.use(allowCrossDomains);
Thanks, works perfectly now.
Wow, that was quick, thanks. From my first attempt to run it I see it still has some issues: 1) To AOT compile you need to export the
MyAuthConfig
class (just add export at the beginning of line 18 at /src/app/app.module.ts 2) The server has to support "cors" I need to add cors library to the server and use it. 3) I've changed the login API from "email" to "username" Stopped testing after that, tell me if you wish to fix those things. If not, I'll probably do it next week when I have time.Thanks again.