azure – Mobile safari: angular http call to .netcore backend – 0 Unknown error

I have an angular application hosted in a web app in azure. It was created using the template in VS with a .Net Core back end. When the application is deployed it works fine on desktops, windows and macOS.

But on mobile safari I keep getting errors when trying to make an api call to fetch a token using azure b2c. The .net core code makes the call in order to get the token and return any other associated data from the database.

I’ve added application insights logging and get the following error:

{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"**********.azurewebsites.net/Auth/Token","ok":false,"name":"HttpErrorResponse","message":"Http failure response for ***********.azurewebsites.net/Auth/Token: 0 Unknown Error","error":{"isTrusted":true}}

This causes my application to go through a looping mechanism from my error page to try and authenticate. After searching endlessly on the web, I’ve ensured CORS is configured correctly and headers are set. But I’m really not sure where to go next.

.net core start up code:

 public void ConfigureServices(IServiceCollection services)
        {
            services.AddApplicationInsightsTelemetry(Configuration("ApplicationInsights:InstrumentationKey") ?? string.Empty);

            ConfigureIoC(services);

            MapperConfiguration mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new AutoMapperConfig());
            });
            services.AddSingleton(mappingConfig.CreateMapper());

            services.AddCors();

            services.AddControllersWithViews(options =>
            {
                options.RespectBrowserAcceptHeader = true;
            }).AddNewtonsoftJson();

            //Azure AD - B2C
            ConfigureAuth(services);
            
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
        }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                IdentityModelEventSource.ShowPII = true;
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            if (!env.IsDevelopment())
            {
                app.UseSpaStaticFiles();
            }

            app.UseRouting();
            app.UseCors(builder => {
                builder.AllowAnyOrigin();
                builder.AllowAnyMethod();
                builder.AllowAnyHeader();
            });
            app.UseAuthentication();
            app.UseAuthorization();
            
            app.UseMiddleware<ErrorHandlingMiddleware>();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                    spa.Options.StartupTimeout = TimeSpan.FromSeconds(200);
                }
            });
        }
    }

Angular http intercepter code:

 intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any> | any> {
    return next.handle(this.addTokenToRequest(request, this.authService.tokenSubject.value)).pipe(
      tap(res => {
        if (res instanceof HttpResponse) {
          this.decreaseRequests();
        }
      }),
      catchError(err => {
        this.decreaseRequests();
      
        if (err instanceof HttpErrorResponse) {
          switch ((<HttpErrorResponse>err).status) {
            case 401:
              this.authService.logOut();
              return;
              //return this.handle401Error(request, next);
            case 200:
              return;
            default:
              return this.handleError(err);
          }
        } else {
          this.logger.logTrace(`Interceptor: Error - ${err}`);
          return throwError(err);
        }
      })
    );
  };

  private decreaseRequests() {
    this.totalRequests--;
  }

  private addTokenToRequest(request: HttpRequest<any>, token: string): HttpRequest<any> {
    return request.clone({
      headers: new HttpHeaders({
        'Content-Type': 'application/json',
        Accept: 'application/json',
        Authorization: 'Bearer ' + token
      })
    });
  }

When running fiddler, this is my request:
fiddler-image

safari – Can I recover my history?

safari – Can I recover my history? – Ask Different

Desert Safari Dubai

Dubai is one of the most famous entertainment and fun hub in the world. There are many tourist attractions in Dubai. One of them is a special tour known as the desert safari Dubai deals. This tour is specially organized for low budget visitors keeping all the fun the same as in other tours. This is a special limited-time offer so hurry up and book it before we go for full price.

.

Big Sur Add trusted certificate via command line (Safari Can’t establish a secure connection)

I am trying to have safari stop preventing me from visiting one of my dev machines with an invalid cert.

I am trying to use the solution in This Thread but install it using the CLI:

   security add-trusted-cert  -r trustRoot  -k ~/Library/Keychains/login.keychain-db /tmp/test.cert

I am still receiving the “Safari Can’t Open the Page because Safari can’t establish a secure connection to the server” error.

I want it to be applied to the user so I don’t want to do the -d flag. And I know I am correctly downloading the cert because if I add the certificate and trust it through the OSX GUI, it works fine.

Another interesting note is that this solution works for my brave and firefox browsers, so it’s just safari that is giving me grief, but even safari works when I add the downloaded cert via the GUI.

safari – What are safe files to delete to free up space?

Apart from deleting old documents and apps that are no longer useful or can be re-downloaded again from the App Store (like iMovie / Garageband), what can safely be deleted from a Macbook Pro?

I deleted Caches from Users/John Doe/Library/Containers/com.apple.safari which was 1.1GB, which contained a WebKit folder and a few other ones.

In general, if you ignore the /var/ directory, what files from the Users/USERNAME/Library and the Library directory (aside from Caches very infrequently) are safe to delete to free up space and will have no major consequences on the OS?

This is for a MacBook Pro 2020 with Catalina that’s got flash storage (isn’t that the same as SSD) according to About this Mac.

Open link in new private window on iPad with safari

In order to avoid cluttering my history and such I often want to quickly open links in a private window. This is in the middle of a non private session.

How I do this in Chrome:

  1. Long press link
  2. Open in incognito tab

Is there a quick way to do this in Safari on iPad as well?

So far the quickest path I found is as follows:

  1. Long press link
  2. Copy
  3. Long press tab list
  4. New private tab
  5. Long press address bar
  6. Paste and go

Not only is this a long process, it also flushes my clipboard which can mean extra time lost.

I know there are ways to work around this, like using a different browser, but I just wonder if there is a way to do this in safari.

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123