React server side rendering: unable to verify the first certificate #609

Closed
opened 2025-08-09 17:16:57 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @JoshClose on 7/4/2017

I'm running on https. I can't seem to figure out why I'm getting this error. Everything looks roughly the same to me as the code generated from using yo to create a react/redux app. If I remove the [Authorize] app from the controller, the issue still happens. I've read this is supposed to work on this issue https://github.com/aspnet/JavaScriptServices/issues/851. Zone.js isn't in my stack because i'm using fetch from domain-task.

This is the error

Call to Node module failed with error: FetchError: request to https://localhost:44346/api/contracts failed, reason: unable to verify the first certificate
    at ClientRequest.<anonymous> (C:\Users\...\ClientApp\dist\vendor.js:44324:11)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at TLSSocket.socketErrorListener (_http_client.js:309:9)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at emitErrorNT (net.js:1277:8)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)

This is my controller

[Route( "api/[controller]" )]
[Authorize]
public class ContractController : Controller
{
	private readonly ApplicationDbContext context;

	public ContractController( ApplicationDbContext context )
	{
		this.context = context;
	}

	[HttpGet( "/api/contracts" )]
	public object GetContracts()
	{
		var contracts = context.Contracts.ToList();

		return new
		{
			Contracts = contracts
		};
	}
}

This is the js calling it

import { fetch, addTask } from "domain-task"

export const FETCH_CONTRACTS = "ContractActions/FetchContracts"

export const fetchContracts = () => dispatch => {
	let fetchTask = fetch("/api/contracts", {
		method: "GET",
		credentials: "same-origin",
		headers: {
			"Content-Type": "application/json"
		}
	}).then(response => response.json()).then(data => {
		dispatch({
			type: FETCH_CONTRACTS,
			contracts: data.contracts
		});
	});

	addTask(fetchTask);
	dispatch({ type: FETCH_CONTRACTS });
}
*Originally created by @JoshClose on 7/4/2017* I'm running on https. I can't seem to figure out why I'm getting this error. Everything looks roughly the same to me as the code generated from using `yo` to create a react/redux app. If I remove the `[Authorize]` app from the controller, the issue still happens. I've read this is supposed to work on this issue https://github.com/aspnet/JavaScriptServices/issues/851. Zone.js isn't in my stack because i'm using `fetch` from `domain-task`. This is the error ``` Call to Node module failed with error: FetchError: request to https://localhost:44346/api/contracts failed, reason: unable to verify the first certificate at ClientRequest.<anonymous> (C:\Users\...\ClientApp\dist\vendor.js:44324:11) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at TLSSocket.socketErrorListener (_http_client.js:309:9) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at emitErrorNT (net.js:1277:8) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9) ``` This is my controller ```cs [Route( "api/[controller]" )] [Authorize] public class ContractController : Controller { private readonly ApplicationDbContext context; public ContractController( ApplicationDbContext context ) { this.context = context; } [HttpGet( "/api/contracts" )] public object GetContracts() { var contracts = context.Contracts.ToList(); return new { Contracts = contracts }; } } ``` This is the js calling it ```js import { fetch, addTask } from "domain-task" export const FETCH_CONTRACTS = "ContractActions/FetchContracts" export const fetchContracts = () => dispatch => { let fetchTask = fetch("/api/contracts", { method: "GET", credentials: "same-origin", headers: { "Content-Type": "application/json" } }).then(response => response.json()).then(data => { dispatch({ type: FETCH_CONTRACTS, contracts: data.contracts }); }); addTask(fetchTask); dispatch({ type: FETCH_CONTRACTS }); } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#609
No description provided.