0

I am having the weirdest issue trying to upload files to a server behind OpenVPN CloudConnexa. Every time I send the post request I get a net::ERR_CONNECTION_RESET. The request won't even reach my NGINX reverse-proxy in front of my REST API Error Message

Here are the access logs from NGINX:

enter image description here

As you can see the preflight CORS request is successful but the actual POST doesn't even reach the server.

Here's the code that sends the request:

import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
import { environment } from 'src/environments/environment'

@Injectable({
  providedIn: 'root'
})
export class ImagesService {
  constructor(private http: HttpClient) { }

  uploadImage(image: File): Observable<any> {
    const formData = new FormData()
    formData.append('image', image)
    return this.http.post(`${environment.apiUrl}/upload/images/${image.name}`, formData)
  }
}

Note that this works perfectly fine locally and for all other requests (GET, PUT, POST) for JSON content. The issue arises when I am trying to reach the server through CloudConnexa VPN's.

I tried using axios instead of angular's default HttpClient. Same issue...

import { HttpClient } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Observable, of } from 'rxjs'
import { environment } from 'src/environments/environment'
import axios from 'axios'

@Injectable({
  providedIn: 'root'
})
export class ImagesService {
  constructor(private http: HttpClient) { }

  uploadImage(image: File): Observable<any> {
    const formData = new FormData()
    formData.append('image', image)

    axios.post(`${environment.apiUrl}/upload/images/${image.name}`, formData)
    return of({})
  }
}

enter image description here

Now I hear you say the issue must come from CloudConnexa configuration somehow but then I try the same request using Postman and it works...

enter image description here

All headers are pretty much identical beside User-Agent but I doubt that this is the issue.

Anyway, thanks for your help

g1n93r
  • 11
  • 1

0 Answers0