The negotiation URL is not correctly set while initiating Signal R connection in next js PRODUCTION build (using yarn build command). It's works fine with development build (using yarn dev command)
Local build signal R log - Sending negotiation request to given URL while initiating Signalr
Production build Signal R log- Sending negotiation request is missing the actual URL that is passed while initiating Signalr, Throws error _app-981b32fff10f13a9.js:2 POST http://localhost:3000/register/pre-fetch?negotiateVersion=1 405 (Method Not Allowed) here negotiation request URL is changed to " http://localhost:3000/register/pre-fetch?negotiateVersion=1" which is a component path from where signal R initiated, this should be: https:/{{SignalrURL}}/negotiate?negotiateVersion=1.
signal.ts file
import * as signalR from '@microsoft/signalr';
const conn = new signalR.HubConnectionBuilder()
.withUrl('SignalrURL',
{ accessTokenFactory: () => localStorage.getItem('token') })
.withAutomaticReconnect()
.configureLogging(signalR.LogLevel.Debug)
.build()
.start();
package.json
"dependencies": {
"@deere/fuel-react": "^3.0.0",
"@microsoft/signalr": "^7.0.0",
"@mui/icons-material": "^5.10.14",
"@mui/x-data-grid": "^5.17.14",
"@reduxjs/toolkit": "^1.9.1",
"@sentry/nextjs": "^7.23.0",
"applicationinsights": "^2.3.6",
"axios": "^1.2.0",
"moment": "^2.29.4",
"moment-timezone": "^0.5.38",
"net": "^1.0.2",
"next": "13.0.4",
"next-auth": "^4.18.4",
"nextjs-redirect": "^6.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-intl": "^6.2.1",
"react-redux": "^8.0.5",
"react-test-renderer": "^18.2.0",
"react-toastify": "^9.1.1",
"rxjs": "^7.6.0",
"tls": "^0.0.1",
"v8": "^0.1.0"
},