aspnetcore-angular-universal icon indicating copy to clipboard operation
aspnetcore-angular-universal copied to clipboard

HTTPS breaks SSR api calls

Open vmural opened this issue 7 years ago • 10 comments

I use starter, and in production i have error fail: Microsoft.AspNetCore.NodeServices[0] ERROR Response { _body: ProgressEvent { type: 'error', target: XMLHttpRequest { onloadstart: null, onprogress: null, onabort: null, onerror: null, onload: null, ontimeout: null, onloadend: null, _listeners: [Object], onreadystatechange: null, _anonymous: undefined, readyState: 4, response: null, responseText: '', responseType: '', responseURL: '', status: 0, statusText: '', timeout: 0, upload: [Object], _method: 'GET', _url: [Object], _sync: false, _headers: [Object], _loweredHeaders: [Object], _mimeOverride: null, _request: null, _response: null, _responseParts: null, _responseHeaders: null, _aborting: null, _error: null, _loadedBytes: 0, _totalBytes: 0, _lengthComputable: false }, currentTarget: XMLHttpRequest { onloadstart: null, onprogress: null, onabort: null, onerror: null, onload: null, ontimeout: null, onloadend: null, _listeners: [Object], onreadystatechange: null, _anonymous: undefined, readyState: 4, response: null, responseText: '', responseType: '', responseURL: '', status: 0, statusText: '', timeout: 0, upload: [Object], _method: 'GET', _url: [Object], _sync: false, _headers: [Object], _loweredHeaders: [Object], _mimeOverride: null, _request: null, _response: null, _responseParts: null, _responseHeaders: null, _aborting: null, _error: null, _loadedBytes: 0, _totalBytes: 0, _lengthComputable: false }, lengthComputable: false, loaded: 0, total: 0 }, status: 0, ok: false, statusText: '', headers: Headers { _headers: Map {}, _normalizedNames: Map {} }, type: 3, url: null }

vmural avatar Jan 11 '18 19:01 vmural

Hey there, what are you trying to do?

MarkPieszak avatar Jan 12 '18 17:01 MarkPieszak

Hi, I built everything on your starter, when posting on iis everything works well with http but on https there is such a bug, and there are no tags in the page code (description, title) and this page impression is simply rendered to un universally when switching back to http all the data is what can be? mayby transferHttp not working in this mode

vmural avatar Jan 12 '18 17:01 vmural

Hi Im not sure if this is related, but when you turn https on the SSR API-calls break.

lgoudriaan avatar Jan 18 '18 20:01 lgoudriaan

@lgoudriaan yes, with ssr and https api rendering does not work correctly

vmural avatar Jan 18 '18 20:01 vmural

Ah found the same error in the server output. Maybe change the issue title to: HTTPS breaks SSR api calls

lgoudriaan avatar Jan 18 '18 20:01 lgoudriaan

@lgoudriaan did not find a way to fix it?

vmural avatar Jan 18 '18 20:01 vmural

Nope :( just found out that https broke the api calls. I also don't know how to debug this.

lgoudriaan avatar Jan 18 '18 20:01 lgoudriaan

What's the actual response on the server? Are you including the ANTI-CSRF cookies as well on the call? or are you just doing a get/post directly from postman?

rufogongora avatar Jan 31 '18 15:01 rufogongora

@rufogongora its just the normal response, but it's not executed on the server.

With the new version (angular 5+) the api call is executed twice, 1 via server, 1 via client.

lgoudriaan avatar Feb 01 '18 18:02 lgoudriaan

cors didnot help

i find solution! ssr starts on random port, so it has different baseUrl than our localhost. for example web api serve on http://localhost:5000 and https://localhost:5001 and our ssr served on http://localhost:56789(for example). so our ssr calls request like this: http://localhost:56789/api/fetch. so it is not our web api. we make shure that we call api by our dedicated localhost:5000 or localhost:5001. and everything will work. i'll publish my own repo soon

hartov avatar Dec 25 '18 19:12 hartov