0

I have been using Nginx for my angular2 application. now I decided to migrate to the angular-CLI server. I am facing issues with setting cookies

In Nginx, I use proxy_cookie_path to define cookie path. how to do this in angular CLI

server {
        listen 80;
        server_name "a2distribution-local.com";
        location / {
                root /Users/mypc/Documents/angular2Distribution/ ;
                try_files $uri $uri/ /index.html =404;
                }
        location /rest/ {
                       proxy_set_header Host $host;
                       proxy_set_header X-Real-IP $remote_addr;
                       proxy_pass http://localhost:8080/cloudface/;
                       proxy_cookie_path /cloudface/  /;
               }
             }

How to achieve this configuration in angular CLI.

6
  • Angular-CLI is a development-only server. It's not indended for production. Commented Apr 17, 2017 at 8:58
  • yeah, that I got it. I want these setup for development only. In production I still use Nginx. Commented Apr 17, 2017 at 9:01
  • @JBNizet. any ideas. how to implement that Commented Apr 17, 2017 at 9:01
  • Why would you have to set cookies from the angular cli server? How could you? All it does is serve your static assets (images, generated JS bundles, index.html). What are you trying to achieve? Commented Apr 17, 2017 at 9:04
  • I have an authentication system based on the cookie. how could I test without setting a cookie? can angular CLI server store a cookie? Commented Apr 17, 2017 at 9:06

1 Answer 1

1

Angular Cli uses webpack-dev-server which inherently uses http-proxy-middleware for proxy the hood.

take a look at the provided options for http-proxy-middleware. I don't see any options that suit your need. However, this may be helpful for others.

For proxy examples, take a look at examples in the cli wiki:

  1. using-corporate-proxy
  2. proxy to back-end
Sign up to request clarification or add additional context in comments.

1 Comment

currently, I am using '' document.cookie" as a hotfix to store my cookie.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.