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
Here are the access logs from NGINX:
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({})
}
}
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...
All headers are pretty much identical beside User-Agent but I doubt that this is the issue.
Anyway, thanks for your help