I uploaded my backend to Heroku. However, when I do a fetch POST request from Netlify to the Heroku backend, I got this:
Bad response! Please check your url. Status Code: 403
The backend runs but it gives me an error. Thanks............................................................................................................................................................................................
Log Error:
> 2022-08-15T05:04:32.880478+00:00 heroku[router]: at=info
> method=OPTIONS path="/data" host=final-final-final-app.herokuapp.com
> request_id=92b0787f-3509-4cae-aabc-499e1f69f104 fwd="98.59.250.254"
> dyno=web.1 connect=0ms service=2ms status=204 bytes=301
> protocol=https2022-08-15T05:04:33.017407+00:00 app[web.1]:
> _events: [Object: null prototype],2022-08-15T05:04:33.017407+00:00 app[web.1]: _eventsCount: 2,2022-08-15T05:04:33.017408+00:00
> app[web.1]: _maxListeners:
> undefined,2022-08-15T05:04:33.017408+00:00 app[web.1]:
> defaultPort: 80,2022-08-15T05:04:33.017408+00:00 app[web.1]:
> protocol: 'http:',2022-08-15T05:04:33.017408+00:00 app[web.1]:
> options: [Object: null prototype],2022-08-15T05:04:33.017408+00:00
> app[web.1]: requests: [Object: null prototype]
> {},2022-08-15T05:04:33.017408+00:00 app[web.1]: sockets:
> [Object: null prototype],2022-08-15T05:04:33.017409+00:00 app[web.1]:
> freeSockets: [Object: null prototype]
> {},2022-08-15T05:04:33.017409+00:00 app[web.1]: keepAliveMsecs:
> 1000,2022-08-15T05:04:33.017409+00:00 app[web.1]: keepAlive:
> false,2022-08-15T05:04:33.017409+00:00 app[web.1]: maxSockets:
> Infinity,2022-08-15T05:04:33.017409+00:00 app[web.1]:
> maxFreeSockets: 256,2022-08-15T05:04:33.017409+00:00 app[web.1]:
> scheduling: 'lifo',2022-08-15T05:04:33.017409+00:00 app[web.1]:
> maxTotalSockets: Infinity,2022-08-15T05:04:33.017410+00:00 app[web.1]:
> totalSocketCount: 1,2022-08-15T05:04:33.017410+00:00 app[web.1]:
> [Symbol(kCapture)]: false2022-08-15T05:04:33.017410+00:00 app[web.1]:
> },2022-08-15T05:04:33.017410+00:00 app[web.1]: socketPath:
> undefined,2022-08-15T05:04:33.017410+00:00 app[web.1]: method:
> 'GET',2022-08-15T05:04:33.017410+00:00 app[web.1]: maxHeaderSize:
> undefined,2022-08-15T05:04:33.017410+00:00 app[web.1]:
> insecureHTTPParser: undefined,2022-08-15T05:04:33.017411+00:00
> app[web.1]: path:
> '/api/search.php?from=LAX&to=SEA&depart=2022-08-24&sort=cost',2022-08-15T05:04:33.017411+00:00
> app[web.1]: _ended: false,2022-08-15T05:04:33.017411+00:00
> app[web.1]: res: [Circular *2],2022-08-15T05:04:33.017411+00:00
> app[web.1]: aborted: false,2022-08-15T05:04:33.017411+00:00
> app[web.1]: timeoutCb: null,2022-08-15T05:04:33.017411+00:00
> app[web.1]: upgradeOrConnect:
> false,2022-08-15T05:04:33.017411+00:00 app[web.1]: parser:
> HTTPParser {2022-08-15T05:04:33.017412+00:00 app[web.1]: '0':
> null,2022-08-15T05:04:33.017412+00:00 app[web.1]: '1':
> [Function: parserOnHeaders],2022-08-15T05:04:33.017412+00:00
> app[web.1]: '2': [Function:
> parserOnHeadersComplete],2022-08-15T05:04:33.017412+00:00 app[web.1]:
> '3': [Function: parserOnBody],2022-08-15T05:04:33.017412+00:00
> app[web.1]: '4': [Function:
> parserOnMessageComplete],2022-08-15T05:04:33.017412+00:00 app[web.1]:
> '5': null,2022-08-15T05:04:33.017413+00:00 app[web.1]: '6':
> null,2022-08-15T05:04:33.017413+00:00 app[web.1]: _headers:
> [],2022-08-15T05:04:33.017413+00:00 app[web.1]: _url:
> '',2022-08-15T05:04:33.017413+00:00 app[web.1]: socket:
> [Socket],2022-08-15T05:04:33.017413+00:00 app[web.1]: incoming:
> [Circular *2],2022-08-15T05:04:33.017413+00:00 app[web.1]:
> outgoing: [Circular *3],2022-08-15T05:04:33.017414+00:00 app[web.1]:
> maxHeaderPairs: 2000,2022-08-15T05:04:33.017414+00:00 app[web.1]:
> _consumed: false,2022-08-15T05:04:33.017414+00:00 app[web.1]: onIncoming: [Function:
> parserOnIncomingClient],2022-08-15T05:04:33.017414+00:00 app[web.1]:
> [Symbol(resource_symbol)]:
> [HTTPClientAsyncResource]2022-08-15T05:04:33.017414+00:00 app[web.1]:
> },2022-08-15T05:04:33.017414+00:00 app[web.1]: maxHeadersCount:
> null,2022-08-15T05:04:33.017415+00:00 app[web.1]: reusedSocket:
> false,2022-08-15T05:04:33.017415+00:00 app[web.1]: host:
> 'skiplagged.com',2022-08-15T05:04:33.017415+00:00 app[web.1]:
> protocol: 'http:',2022-08-15T05:04:33.017415+00:00 app[web.1]:
> [Symbol(kCapture)]: false,2022-08-15T05:04:33.017415+00:00 app[web.1]:
> [Symbol(kNeedDrain)]: false,2022-08-15T05:04:33.017415+00:00
> app[web.1]: [Symbol(corked)]: 0,2022-08-15T05:04:33.017416+00:00
> app[web.1]: [Symbol(kOutHeaders)]: [Object: null prototype] {
> host: [Array] }2022-08-15T05:04:33.017416+00:00 app[web.1]:
> },2022-08-15T05:04:33.017416+00:00 app[web.1]: [Symbol(kCapture)]:
> false,2022-08-15T05:04:33.017416+00:00 app[web.1]:
> [Symbol(kHeaders)]: null,2022-08-15T05:04:33.017416+00:00 app[web.1]:
> [Symbol(kHeadersCount)]: 24,2022-08-15T05:04:33.017416+00:00
> app[web.1]: [Symbol(kTrailers)]:
> null,2022-08-15T05:04:33.017416+00:00 app[web.1]:
> [Symbol(kTrailersCount)]: 0,2022-08-15T05:04:33.017417+00:00
> app[web.1]: [Symbol(RequestTimeout)]:
> undefined2022-08-15T05:04:33.017417+00:00 app[web.1]:
> }2022-08-15T05:04:33.017275+00:00 app[web.1]: <ref *2> IncomingMessage
> {2022-08-15T05:04:33.017282+00:00 app[web.1]: _readableState:
> ReadableState {2022-08-15T05:04:33.017282+00:00 app[web.1]:
> objectMode: false,2022-08-15T05:04:33.017283+00:00 app[web.1]:
> highWaterMark: 16384,2022-08-15T05:04:33.017283+00:00 app[web.1]:
> buffer: BufferList { head: null, tail: null, length: 0
> },2022-08-15T05:04:33.017284+00:00 app[web.1]: length:
> 0,2022-08-15T05:04:33.017284+00:00 app[web.1]: pipes:
> [],2022-08-15T05:04:33.017284+00:00 app[web.1]: flowing:
> null,2022-08-15T05:04:33.017284+00:00 app[web.1]: ended:
> false,2022-08-15T05:04:33.017284+00:00 app[web.1]: endEmitted:
> false,2022-08-15T05:04:33.017285+00:00 app[web.1]: reading:
> false,2022-08-15T05:04:33.017285+00:00 app[web.1]: constructed:
> true,2022-08-15T05:04:33.017285+00:00 app[web.1]: sync:
> true,2022-08-15T05:04:33.017285+00:00 app[web.1]: needReadable:
> false,2022-08-15T05:04:33.017286+00:00 app[web.1]:
> emittedReadable: false,2022-08-15T05:04:33.017286+00:00 app[web.1]:
> readableListening: false,2022-08-15T05:04:33.017286+00:00 app[web.1]:
> resumeScheduled: false,2022-08-15T05:04:33.017286+00:00 app[web.1]:
> errorEmitted: false,2022-08-15T05:04:33.017286+00:00 app[web.1]:
> emitClose: true,2022-08-15T05:04:33.017287+00:00 app[web.1]:
> autoDestroy: true,2022-08-15T05:04:33.017287+00:00 app[web.1]:
> destroyed: false,2022-08-15T05:04:33.017287+00:00 app[web.1]:
> errored: null,2022-08-15T05:04:33.017287+00:00 app[web.1]: closed:
> false,2022-08-15T05:04:33.017287+00:00 app[web.1]: closeEmitted:
> false,2022-08-15T05:04:33.017287+00:00 app[web.1]:
> defaultEncoding: 'utf8',2022-08-15T05:04:33.017288+00:00 app[web.1]:
> awaitDrainWriters: null,2022-08-15T05:04:33.017288+00:00 app[web.1]:
> multiAwaitDrain: false,2022-08-15T05:04:33.017288+00:00 app[web.1]:
> readingMore: true,2022-08-15T05:04:33.017288+00:00 app[web.1]:
> dataEmitted: false,2022-08-15T05:04:33.017288+00:00 app[web.1]:
> decoder: null,2022-08-15T05:04:33.017288+00:00 app[web.1]:
> encoding: null,2022-08-15T05:04:33.017289+00:00 app[web.1]:
> [Symbol(kPaused)]: null2022-08-15T05:04:33.017289+00:00 app[web.1]:
> },2022-08-15T05:04:33.017289+00:00 app[web.1]: _events: [Object:
> null prototype] { end: [Function: responseOnEnd]
> },2022-08-15T05:04:33.017290+00:00 app[web.1]: _eventsCount:
> 1,2022-08-15T05:04:33.017290+00:00 app[web.1]: _maxListeners:
> undefined,2022-08-15T05:04:33.017290+00:00 app[web.1]: socket: <ref
> *1> Socket {2022-08-15T05:04:33.017290+00:00 app[web.1]: connecting: false,2022-08-15T05:04:33.017290+00:00 app[web.1]:
> _hadError: false,2022-08-15T05:04:33.017290+00:00 app[web.1]: _parent: null,2022-08-15T05:04:33.017290+00:00 app[web.1]: _host: 'skiplagged.com',2022-08-15T05:04:33.017290+00:00 app[web.1]:
> _readableState: ReadableState {2022-08-15T05:04:33.017291+00:00 app[web.1]: objectMode: false,2022-08-15T05:04:33.017291+00:00
> app[web.1]: highWaterMark:
> 16384,2022-08-15T05:04:33.017291+00:00 app[web.1]: buffer:
> BufferList { head: null, tail: null, length: 0
> },2022-08-15T05:04:33.017291+00:00 app[web.1]: length:
> 0,2022-08-15T05:04:33.017291+00:00 app[web.1]: pipes:
> [],2022-08-15T05:04:33.017291+00:00 app[web.1]: flowing:
> true,2022-08-15T05:04:33.017291+00:00 app[web.1]: ended:
> false,2022-08-15T05:04:33.017292+00:00 app[web.1]: endEmitted:
> false,2022-08-15T05:04:33.017292+00:00 app[web.1]: reading:
> false,2022-08-15T05:04:33.017292+00:00 app[web.1]: constructed:
> true,2022-08-15T05:04:33.017292+00:00 app[web.1]: sync:
> false,2022-08-15T05:04:33.017292+00:00 app[web.1]: needReadable:
> true,2022-08-15T05:04:33.017292+00:00 app[web.1]:
> emittedReadable: false,2022-08-15T05:04:33.017292+00:00 app[web.1]:
> readableListening: false,2022-08-15T05:04:33.017292+00:00 app[web.1]:
> resumeScheduled: false,2022-08-15T05:04:33.017293+00:00 app[web.1]:
> errorEmitted: false,2022-08-15T05:04:33.017293+00:00 app[web.1]:
> emitClose: false,2022-08-15T05:04:33.017293+00:00 app[web.1]:
> autoDestroy: true,2022-08-15T05:04:33.017293+00:00 app[web.1]:
> destroyed: false,2022-08-15T05:04:33.017293+00:00 app[web.1]:
> errored: null,2022-08-15T05:04:33.017293+00:00 app[web.1]:
> closed: false,2022-08-15T05:04:33.017293+00:00 app[web.1]:
> closeEmitted: false,2022-08-15T05:04:33.017293+00:00 app[web.1]:
> defaultEncoding: 'utf8',2022-08-15T05:04:33.017294+00:00 app[web.1]:
> awaitDrainWriters: null,2022-08-15T05:04:33.017294+00:00 app[web.1]:
> multiAwaitDrain: false,2022-08-15T05:04:33.017294+00:00 app[web.1]:
> readingMore: false,2022-08-15T05:04:33.017294+00:00 app[web.1]:
> dataEmitted: true,2022-08-15T05:04:33.017294+00:00 app[web.1]:
> decoder: null,2022-08-15T05:04:33.017294+00:00 app[web.1]:
> encoding: null,2022-08-15T05:04:33.017294+00:00 app[web.1]:
> [Symbol(kPaused)]: false2022-08-15T05:04:33.017294+00:00 app[web.1]:
> },2022-08-15T05:04:33.017295+00:00 app[web.1]: _events: [Object:
> null prototype] {2022-08-15T05:04:33.017295+00:00 app[web.1]:
> end: [Array],2022-08-15T05:04:33.017295+00:00 app[web.1]: free:
> [Function: onFree],2022-08-15T05:04:33.017295+00:00 app[web.1]:
> close: [Array],2022-08-15T05:04:33.017295+00:00 app[web.1]:
> timeout: [Array],2022-08-15T05:04:33.017295+00:00 app[web.1]:
> agentRemove: [Function: onRemove],2022-08-15T05:04:33.017295+00:00
> app[web.1]: error: [Function:
> socketErrorListener],2022-08-15T05:04:33.017296+00:00 app[web.1]:
> data: [Function: socketOnData],2022-08-15T05:04:33.017296+00:00
> app[web.1]: drain: [Function:
> ondrain]2022-08-15T05:04:33.017296+00:00 app[web.1]:
> },2022-08-15T05:04:33.017296+00:00 app[web.1]: _eventsCount:
> 8,2022-08-15T05:04:33.017296+00:00 app[web.1]: _maxListeners:
> undefined,2022-08-15T05:04:33.017296+00:00 app[web.1]:
> _writableState: WritableState {2022-08-15T05:04:33.017297+00:00 app[web.1]: objectMode: false,2022-08-15T05:04:33.017297+00:00
> app[web.1]: highWaterMark:
> 16384,2022-08-15T05:04:33.017297+00:00 app[web.1]: finalCalled:
> false,2022-08-15T05:04:33.017297+00:00 app[web.1]: needDrain:
> false,2022-08-15T05:04:33.017297+00:00 app[web.1]: ending:
> false,2022-08-15T05:04:33.017297+00:00 app[web.1]: ended:
> false,2022-08-15T05:04:33.017299+00:00 app[web.1]: finished:
> false,2022-08-15T05:04:33.017299+00:00 app[web.1]: destroyed:
> false,2022-08-15T05:04:33.017299+00:00 app[web.1]:
> decodeStrings: false,2022-08-15T05:04:33.017299+00:00 app[web.1]:
> defaultEncoding: 'utf8',2022-08-15T05:04:33.017300+00:00 app[web.1]:
> length: 0,2022-08-15T05:04:33.017300+00:00 app[web.1]: writing:
> false,2022-08-15T05:04:33.017300+00:00 app[web.1]: corked:
> 0,2022-08-15T05:04:33.017300+00:00 app[web.1]: sync:
> false,2022-08-15T05:04:33.017300+00:00 app[web.1]:
> bufferProcessing: false,2022-08-15T05:04:33.017301+00:00 app[web.1]:
> onwrite: [Function: bound onwrite],2022-08-15T05:04:33.017301+00:00
> app[web.1]: writecb: null,2022-08-15T05:04:33.017301+00:00
> app[web.1]: writelen: 0,2022-08-15T05:04:33.017301+00:00
> app[web.1]: afterWriteTickInfo:
> null,2022-08-15T05:04:33.017301+00:00 app[web.1]: buffered:
> [],2022-08-15T05:04:33.017301+00:00 app[web.1]: bufferedIndex:
> 0,2022-08-15T05:04:33.017301+00:00 app[web.1]: allBuffers:
> true,2022-08-15T05:04:33.017302+00:00 app[web.1]: allNoop:
> true,2022-08-15T05:04:33.017302+00:00 app[web.1]: pendingcb:
> 0,2022-08-15T05:04:33.017302+00:00 app[web.1]: constructed:
> true,2022-08-15T05:04:33.017302+00:00 app[web.1]: prefinished:
> false,2022-08-15T05:04:33.017302+00:00 app[web.1]: errorEmitted:
> false,2022-08-15T05:04:33.017302+00:00 app[web.1]: emitClose:
> false,2022-08-15T05:04:33.017302+00:00 app[web.1]: autoDestroy:
> true,2022-08-15T05:04:33.017302+00:00 app[web.1]: errored:
> null,2022-08-15T05:04:33.017303+00:00 app[web.1]: closed:
> false,2022-08-15T05:04:33.017303+00:00 app[web.1]: closeEmitted:
> false,2022-08-15T05:04:33.017303+00:00 app[web.1]:
> [Symbol(kOnFinished)]: []2022-08-15T05:04:33.017303+00:00 app[web.1]:
> },2022-08-15T05:04:33.017303+00:00 app[web.1]: allowHalfOpen:
> false,2022-08-15T05:04:33.017303+00:00 app[web.1]: _sockname:
> null,2022-08-15T05:04:33.017303+00:00 app[web.1]: _pendingData:
> null,2022-08-15T05:04:33.017304+00:00 app[web.1]:
> _pendingEncoding: '',2022-08-15T05:04:33.017304+00:00 app[web.1]: server: null,2022-08-15T05:04:33.017304+00:00 app[web.1]: _server:
> null,2022-08-15T05:04:33.017304+00:00 app[web.1]: parser:
> HTTPParser {2022-08-15T05:04:33.017304+00:00 app[web.1]: '0':
> null,2022-08-15T05:04:33.017304+00:00 app[web.1]: '1':
> [Function: parserOnHeaders],2022-08-15T05:04:33.017304+00:00
> app[web.1]: '2': [Function:
> parserOnHeadersComplete],2022-08-15T05:04:33.017305+00:00 app[web.1]:
> '3': [Function: parserOnBody],2022-08-15T05:04:33.017305+00:00
> app[web.1]: '4': [Function:
> parserOnMessageComplete],2022-08-15T05:04:33.017305+00:00 app[web.1]:
> '5': null,2022-08-15T05:04:33.017305+00:00 app[web.1]: '6':
> null,2022-08-15T05:04:33.017305+00:00 app[web.1]: _headers:
> [],2022-08-15T05:04:33.017306+00:00 app[web.1]: _url:
> '',2022-08-15T05:04:33.017306+00:00 app[web.1]: socket:
> [Circular *1],2022-08-15T05:04:33.017306+00:00 app[web.1]:
> incoming: [Circular *2],2022-08-15T05:04:33.017306+00:00 app[web.1]:
> outgoing: [ClientRequest],2022-08-15T05:04:33.017306+00:00 app[web.1]:
> maxHeaderPairs: 2000,2022-08-15T05:04:33.017306+00:00 app[web.1]:
> _consumed: false,2022-08-15T05:04:33.017306+00:00 app[web.1]: onIncoming: [Function:
> parserOnIncomingClient],2022-08-15T05:04:33.017306+00:00 app[web.1]:
> [Symbol(resource_symbol)]:
> [HTTPClientAsyncResource]2022-08-15T05:04:33.017307+00:00 app[web.1]:
> },2022-08-15T05:04:33.017307+00:00 app[web.1]: _httpMessage:
> ClientRequest {2022-08-15T05:04:33.017307+00:00 app[web.1]:
> _events: [Object: null prototype],2022-08-15T05:04:33.017307+00:00 app[web.1]: _eventsCount: 2,2022-08-15T05:04:33.017307+00:00
> app[web.1]: _maxListeners:
> undefined,2022-08-15T05:04:33.017307+00:00 app[web.1]:
> outputData: [],2022-08-15T05:04:33.017307+00:00 app[web.1]:
> outputSize: 0,2022-08-15T05:04:33.017308+00:00 app[web.1]:
> writable: true,2022-08-15T05:04:33.017308+00:00 app[web.1]:
> destroyed: false,2022-08-15T05:04:33.017308+00:00 app[web.1]:
> _last: true,2022-08-15T05:04:33.017308+00:00 app[web.1]: chunkedEncoding: false,2022-08-15T05:04:33.017308+00:00 app[web.1]:
> shouldKeepAlive: false,2022-08-15T05:04:33.017308+00:00 app[web.1]:
> maxRequestsOnConnectionReached: false,2022-08-15T05:04:33.017313+00:00
> app[web.1]: _defaultKeepAlive:
> true,2022-08-15T05:04:33.017313+00:00 app[web.1]:
> useChunkedEncodingByDefault: false,2022-08-15T05:04:33.017313+00:00
> app[web.1]: sendDate: false,2022-08-15T05:04:33.017313+00:00
> app[web.1]: _removedConnection:
> false,2022-08-15T05:04:33.017313+00:00 app[web.1]:
> _removedContLen: false,2022-08-15T05:04:33.017313+00:00 app[web.1]: _removedTE: false,2022-08-15T05:04:33.017314+00:00 app[web.1]: _contentLength: 0,2022-08-15T05:04:33.017314+00:00 app[web.1]: _hasBody: true,2022-08-15T05:04:33.017314+00:00 app[web.1]: _trailer: '',2022-08-15T05:04:33.017314+00:00 app[web.1]: finished: true,2022-08-15T05:04:33.017314+00:00 app[web.1]:
> _headerSent: true,2022-08-15T05:04:33.017314+00:00 app[web.1]: _closed: false,2022-08-15T05:04:33.017314+00:00 app[web.1]: socket: [Circular *1],2022-08-15T05:04:33.017315+00:00 app[web.1]:
> _header: 'GET /api/search.php?from=LAX&to=SEA&depart=2022-08-24&sort=cost
> HTTP/1.1\r\n' +2022-08-15T05:04:33.017315+00:00 app[web.1]:
> 'Host: skiplagged.com\r\n' +2022-08-15T05:04:33.017315+00:00
> app[web.1]: 'Connection: close\r\n'
> +2022-08-15T05:04:33.017315+00:00 app[web.1]: '\r\n',2022-08-15T05:04:33.017316+00:00 app[web.1]:
> _keepAliveTimeout: 0,2022-08-15T05:04:33.017316+00:00 app[web.1]: _onPendingData: [Function: nop],2022-08-15T05:04:33.017316+00:00 app[web.1]: agent: [Agent],2022-08-15T05:04:33.017316+00:00
> app[web.1]: socketPath:
> undefined,2022-08-15T05:04:33.017316+00:00 app[web.1]: method:
> 'GET',2022-08-15T05:04:33.017317+00:00 app[web.1]:
> maxHeaderSize: undefined,2022-08-15T05:04:33.017317+00:00 app[web.1]:
> insecureHTTPParser: undefined,2022-08-15T05:04:33.017317+00:00
> app[web.1]: path:
> '/api/search.php?from=LAX&to=SEA&depart=2022-08-24&sort=cost',2022-08-15T05:04:33.017317+00:00
> app[web.1]: _ended: false,2022-08-15T05:04:33.017318+00:00
> app[web.1]: res: [Circular *2],2022-08-15T05:04:33.017318+00:00
> app[web.1]: aborted: false,2022-08-15T05:04:33.017318+00:00
> app[web.1]: timeoutCb: null,2022-08-15T05:04:33.017318+00:00
> app[web.1]: upgradeOrConnect:
> false,2022-08-15T05:04:33.017318+00:00 app[web.1]: parser:
> [HTTPParser],2022-08-15T05:04:33.017319+00:00 app[web.1]:
> maxHeadersCount: null,2022-08-15T05:04:33.017319+00:00 app[web.1]:
> reusedSocket: false,2022-08-15T05:04:33.017319+00:00 app[web.1]:
> host: 'skiplagged.com',2022-08-15T05:04:33.017319+00:00 app[web.1]:
> protocol: 'http:',2022-08-15T05:04:33.017319+00:00 app[web.1]:
> [Symbol(kCapture)]: false,2022-08-15T05:04:33.017319+00:00 app[web.1]:
> [Symbol(kNeedDrain)]: false,2022-08-15T05:04:33.017319+00:00
> app[web.1]: [Symbol(corked)]: 0,2022-08-15T05:04:33.017320+00:00
> app[web.1]: [Symbol(kOutHeaders)]: [Object: null
> prototype]2022-08-15T05:04:33.017320+00:00 app[web.1]:
> },2022-08-15T05:04:33.017320+00:00 app[web.1]:
> [Symbol(async_id_symbol)]: 65,2022-08-15T05:04:33.017320+00:00
> app[web.1]: [Symbol(kHandle)]: TCP
> {2022-08-15T05:04:33.017320+00:00 app[web.1]: reading:
> true,2022-08-15T05:04:33.017320+00:00 app[web.1]: onconnection:
> null,2022-08-15T05:04:33.017320+00:00 app[web.1]:
> [Symbol(owner_symbol)]: [Circular *1]2022-08-15T05:04:33.017321+00:00
> app[web.1]: },2022-08-15T05:04:33.017321+00:00 app[web.1]:
> [Symbol(lastWriteQueueSize)]: 0,2022-08-15T05:04:33.017321+00:00
> app[web.1]: [Symbol(timeout)]:
> null,2022-08-15T05:04:33.017321+00:00 app[web.1]:
> [Symbol(kBuffer)]: null,2022-08-15T05:04:33.017321+00:00 app[web.1]:
> [Symbol(kBufferCb)]: null,2022-08-15T05:04:33.017321+00:00 app[web.1]:
> [Symbol(kBufferGen)]: null,2022-08-15T05:04:33.017321+00:00
> app[web.1]: [Symbol(kCapture)]:
> false,2022-08-15T05:04:33.017322+00:00 app[web.1]:
> [Symbol(kSetNoDelay)]: false,2022-08-15T05:04:33.017322+00:00
> app[web.1]: [Symbol(kSetKeepAlive)]:
> false,2022-08-15T05:04:33.017322+00:00 app[web.1]:
> [Symbol(kSetKeepAliveInitialDelay)]:
> 0,2022-08-15T05:04:33.017322+00:00 app[web.1]:
> [Symbol(kBytesRead)]: 0,2022-08-15T05:04:33.017322+00:00 app[web.1]:
> [Symbol(kBytesWritten)]: 0,2022-08-15T05:04:33.017322+00:00
> app[web.1]: [Symbol(RequestTimeout)]:
> undefined2022-08-15T05:04:33.017323+00:00 app[web.1]:
> },2022-08-15T05:04:33.017323+00:00 app[web.1]: httpVersionMajor:
> 1,2022-08-15T05:04:33.017323+00:00 app[web.1]: httpVersionMinor:
> 1,2022-08-15T05:04:33.017323+00:00 app[web.1]: httpVersion:
> '1.1',2022-08-15T05:04:33.017323+00:00 app[web.1]: complete:
> false,2022-08-15T05:04:33.017323+00:00 app[web.1]: rawHeaders:
> [2022-08-15T05:04:33.017323+00:00 app[web.1]:
> 'Date',2022-08-15T05:04:33.017324+00:00 app[web.1]: 'Mon, 15 Aug
> 2022 05:04:33 GMT',2022-08-15T05:04:33.017324+00:00 app[web.1]:
> 'Content-Type',2022-08-15T05:04:33.017324+00:00 app[web.1]:
> 'text/html; charset=UTF-8',2022-08-15T05:04:33.017324+00:00
> app[web.1]: 'Transfer-Encoding',2022-08-15T05:04:33.017324+00:00
> app[web.1]: 'chunked',2022-08-15T05:04:33.017324+00:00 app[web.1]:
> 'Connection',2022-08-15T05:04:33.017324+00:00 app[web.1]:
> 'close',2022-08-15T05:04:33.017324+00:00 app[web.1]:
> 'CF-Chl-Bypass',2022-08-15T05:04:33.017325+00:00 app[web.1]:
> '1',2022-08-15T05:04:33.017325+00:00 app[web.1]:
> 'Permissions-Policy',2022-08-15T05:04:33.017325+00:00 app[web.1]:
> 'accelerometer=(),autoplay=(),camera=(),clipboard-read=(),clipboard-write=(),fullscreen=(),geolocation=(),gyroscope=(),hid=(),interest-cohort=(),magnetometer=(),microphone=(),payment=(),publickey-credentials-get=(),screen-wake-lock=(),serial=(),sync-xhr=(),usb=()',2022-08-15T05:04:33.017325+00:00
> app[web.1]: 'Cache-Control',2022-08-15T05:04:33.017326+00:00
> app[web.1]: 'private, max-age=0, no-store, no-cache,
> must-revalidate, post-check=0,
> pre-check=0',2022-08-15T05:04:33.017326+00:00 app[web.1]:
> 'Expires',2022-08-15T05:04:33.017326+00:00 app[web.1]: 'Thu, 01
> Jan 1970 00:00:01 GMT',2022-08-15T05:04:33.017326+00:00 app[web.1]:
> 'X-Frame-Options',2022-08-15T05:04:33.017326+00:00 app[web.1]:
> 'SAMEORIGIN',2022-08-15T05:04:33.017326+00:00 app[web.1]:
> 'Server',2022-08-15T05:04:33.017326+00:00 app[web.1]:
> 'cloudflare',2022-08-15T05:04:33.017327+00:00 app[web.1]:
> 'CF-RAY',2022-08-15T05:04:33.017327+00:00 app[web.1]:
> '73af63de3ca4821e-IAD',2022-08-15T05:04:33.017327+00:00 app[web.1]:
> 'alt-svc',2022-08-15T05:04:33.017327+00:00 app[web.1]: 'h3=":443";
> ma=86400, h3-29=":443"; ma=86400'2022-08-15T05:04:33.017327+00:00
> app[web.1]: ],2022-08-15T05:04:33.017327+00:00 app[web.1]:
> rawTrailers: [],2022-08-15T05:04:33.017327+00:00 app[web.1]:
> aborted: false,2022-08-15T05:04:33.017328+00:00 app[web.1]: upgrade:
> false,2022-08-15T05:04:33.017328+00:00 app[web.1]: url:
> '',2022-08-15T05:04:33.017328+00:00 app[web.1]: method:
> null,2022-08-15T05:04:33.017328+00:00 app[web.1]: statusCode:
> 403,2022-08-15T05:04:33.017328+00:00 app[web.1]: statusMessage:
> 'Forbidden',2022-08-15T05:04:33.017328+00:00 app[web.1]: client:
> <ref *1> Socket {2022-08-15T05:04:33.017328+00:00 app[web.1]:
> connecting: false,2022-08-15T05:04:33.017328+00:00 app[web.1]:
> _hadError: false,2022-08-15T05:04:33.017329+00:00 app[web.1]: _parent: null,2022-08-15T05:04:33.017329+00:00 app[web.1]: _host: 'skiplagged.com',2022-08-15T05:04:33.017329+00:00 app[web.1]:
> _readableState: ReadableState {2022-08-15T05:04:33.017329+00:00 app[web.1]: objectMode: false,2022-08-15T05:04:33.017329+00:00
> app[web.1]: highWaterMark:
> 16384,2022-08-15T05:04:33.017330+00:00 app[web.1]: buffer:
> BufferList { head: null, tail: null, length: 0
> },2022-08-15T05:04:33.017330+00:00 app[web.1]: length:
> 0,2022-08-15T05:04:33.017330+00:00 app[web.1]: pipes:
> [],2022-08-15T05:04:33.017330+00:00 app[web.1]: flowing:
> true,2022-08-15T05:04:33.017330+00:00 app[web.1]: ended:
> false,2022-08-15T05:04:33.017331+00:00 app[web.1]: endEmitted:
> false,2022-08-15T05:04:33.017331+00:00 app[web.1]: reading:
> false,2022-08-15T05:04:33.017331+00:00 app[web.1]: constructed:
> true,2022-08-15T05:04:33.017332+00:00 app[web.1]: sync:
> false,2022-08-15T05:04:33.017332+00:00 app[web.1]: needReadable:
> true,2022-08-15T05:04:33.017332+00:00 app[web.1]:
> emittedReadable: false,2022-08-15T05:04:33.017332+00:00 app[web.1]:
> readableListening: false,2022-08-15T05:04:33.017333+00:00 app[web.1]:
> resumeScheduled: false,2022-08-15T05:04:33.017333+00:00 app[web.1]:
> errorEmitted: false,2022-08-15T05:04:33.017333+00:00 app[web.1]:
> emitClose: false,2022-08-15T05:04:33.017333+00:00 app[web.1]:
> autoDestroy: true,2022-08-15T05:04:33.017333+00:00 app[web.1]:
> destroyed: false,2022-08-15T05:04:33.017333+00:00 app[web.1]:
> errored: null,2022-08-15T05:04:33.017333+00:00 app[web.1]:
> closed: false,2022-08-15T05:04:33.017334+00:00 app[web.1]:
> closeEmitted: false,2022-08-15T05:04:33.017334+00:00 app[web.1]:
> defaultEncoding: 'utf8',2022-08-15T05:04:33.017334+00:00 app[web.1]:
> awaitDrainWriters: null,2022-08-15T05:04:33.017334+00:00 app[web.1]:
> multiAwaitDrain: false,2022-08-15T05:04:33.017334+00:00 app[web.1]:
> readingMore: false,2022-08-15T05:04:33.017334+00:00 app[web.1]:
> dataEmitted: true,2022-08-15T05:04:33.017335+00:00 app[web.1]:
> decoder: null,2022-08-15T05:04:33.017335+00:00 app[web.1]:
> encoding: null,2022-08-15T05:04:33.017335+00:00 app[web.1]:
> [Symbol(kPaused)]: false2022-08-15T05:04:33.017335+00:00 app[web.1]:
> },2022-08-15T05:04:33.017335+00:00 app[web.1]: _events: [Object:
> null prototype] {2022-08-15T05:04:33.017335+00:00 app[web.1]:
> end: [Array],2022-08-15T05:04:33.017335+00:00 app[web.1]: free:
> [Function: onFree],2022-08-15T05:04:33.017335+00:00 app[web.1]:
> close: [Array],2022-08-15T05:04:33.017336+00:00 app[web.1]:
> timeout: [Array],2022-08-15T05:04:33.017336+00:00 app[web.1]:
> agentRemove: [Function: onRemove],2022-08-15T05:04:33.017336+00:00
> app[web.1]: error: [Function:
> socketErrorListener],2022-08-15T05:04:33.017338+00:00 app[web.1]:
> data: [Function: socketOnData],2022-08-15T05:04:33.017338+00:00
> app[web.1]: drain: [Function:
> ondrain]2022-08-15T05:04:33.017339+00:00 app[web.1]:
> },2022-08-15T05:04:33.017339+00:00 app[web.1]: _eventsCount:
> 8,2022-08-15T05:04:33.017339+00:00 app[web.1]: _maxListeners:
> undefined,2022-08-15T05:04:33.017339+00:00 app[web.1]:
> _writableState: WritableState {2022-08-15T05:04:33.017339+00:00 app[web.1]: objectMode: false,2022-08-15T05:04:33.017339+00:00
> app[web.1]: highWaterMark:
> 16384,2022-08-15T05:04:33.017339+00:00 app[web.1]: finalCalled:
> false,2022-08-15T05:04:33.017340+00:00 app[web.1]: needDrain:
> false,2022-08-15T05:04:33.017340+00:00 app[web.1]: ending:
> false,2022-08-15T05:04:33.017340+00:00 app[web.1]: ended:
> false,2022-08
Implementing paypal in my laravel 5.8 app
I got error :
Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment/PAYID-NNNNNNNNNN/execute.
My control :
public function paypal_payment_execute()
{
// After Step 1
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'NNNNN', // ClientID
'NNNNN' // ClientSecret
)
);
$paymentId = request('paymentId');
$PayerID = request('PayerID');
$payment = Payment::get($paymentId, $apiContext);
$execution = new PaymentExecution();
$execution->setPayerId( $PayerID);
$transaction = new Transaction();
$amount = new Amount();
$details = new Details();
$details->setShipping(1.2)
->setTax(1.3)
->setSubtotal(17.50); //
$amount->setCurrency('USD');
$total_sum= 20; // I check this sum is setShipping + setTax + setSubtotal
$amount->setTotal( (integer)$total_sum);
$amount->setDetails($details);
$transaction->setAmount($amount);
$execution->addTransaction( [ $transaction ] ); // !!! I found that here must be an array?
try {
$result = $payment->execute($execution, $apiContext); // Number of error points at this line
} catch (Exception $pce) {
echo '<pre>::'.print_r( json_decode($pce->getData()) );
die("-1 XXZ app/Http/Controllers/PaymentController.php");
}
return $result;
}
I my browse I see output : https://prnt.sc/od3b6v
1) Can somebody say which kind of error is it ?
2) I see lines like :
$this->logger->info
Is it some logging ? Where can I look into it ?
3) That was very strange that error line was shown and not pre output in try catch block:
I expected to see pce->getData output:
} catch (Exception $pce) {
echo '<pre>::'.print_r( json_decode($pce->getData()) );
die("-1 XXZ app/Http/Controllers/PaymentController.php");
}
4) Searching I net I checked that making payment With JS code I set the same total and return urls, like :
<div id="paypal-button"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
let total_sum= 20
alert( "-123 total_sum::"+(total_sum) )
paypal.Button.render({
// Configure environment
env: 'sandbox',
client: {
sandbox: 'NNNNN',
production: 'demo_production_client_id'
},
locale: 'en_US',
style: {
size: 'small',
color: 'blue',
shape: 'pill',
},
commit: true,
payment: function(data, actions) {
var payment = actions.payment.create({
"note_to_payer": "Contact us for any questions on your order.",
"intent": "sale",
"payer": {
"payment_method": "paypal"
},
redirect_urls : { //redirect_urls
return_url : '...paypal_payment',
cancel_url : '.../paypal_payment_cancel'
},
transactions: [{
amount: {
total: Number( total_sum ),
currency: 'USD'
}
}]
});
return payment;
},
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
return actions.redirect();
});
}
}, '#paypal-button');
</script>
How fix it ?
composer.json :
"type": "project",
"require": {
"php": "^7.1.3",
...
"laravel/framework": "5.8.*",
"paypal/rest-api-sdk-php": "*",
Modified :
No messages inside of PayPal\Exception\PPConnectionException block anyway.
In your link I noticed that currency code must be checked.
I created my account about 2 weeks ago : https://prnt.sc/od385x
Where can I check currency code (and maybe country ) ?
Is it in setting for any app ? I did not find where currency can be entered.
if any webhooks must be defoned? What are they for ?
I see “Upgrade to a business account” link . Can it be relative to my problem?
**Modified # 2:**
I attach error desctiption on my sercer in laravel.log when I got 400 error :
cat laravel.log :
[2019-07-12 07:30:33] local.ERROR: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LUUDOCA2FR59365NU097882X/execute. {"userId":6,"exception":"[object] (PayPal\Exception\PayPalConnectionException(code: 400): Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LUUDOCA2FR59365NU097882X/execute. at /var/www/html/votes/vendor/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php:207)
[stacktrace]
#0 /var/www/html/votes/vendor/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php(78): PayPal\Core\PayPalHttpConnection->execute('{\"payer_id\":\"Z9...')
#1 /var/www/html/votes/vendor/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalResourceModel.php(104): PayPal\Transport\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'POST', '{\"payer_id\":\"Z9...', Array)
#2 /var/www/html/votes/vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php(650): PayPal\Common\PayPalResourceModel::executeCall('/v1/payments/pa...', 'POST', '{\"payer_id\":\"Z9...', NULL, Object(PayPal\Rest\ApiContext), Object(PayPal\Transport\PayPalRestCall))
#3 /var/www/html/votes/app/Http/Controllers/PaymentController.php(108): PayPal\Api\Payment->execute(Object(PayPal\Api\PaymentExecution), Object(PayPal\Rest\ApiContext))
#4 [internal function]: App\Http\Controllers\PaymentController->paypal_payment_execute()
#5 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#6 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('paypal_payment_...', Array)
#7 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\PaymentController), 'paypal_payment_...')
#8 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Route.php(176): Illuminate\Routing\Route->runController()
#9 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(680): Illuminate\Routing\Route->run()
#10 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#11 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#12 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#13 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#14 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(75): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#15 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#16 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#17 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#18 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#19 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(56): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#21 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#22 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#23 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#24 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#25 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#26 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#27 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#30 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(682): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#31 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(657): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#32 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(623): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#33 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Router.php(612): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#34 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#35 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#36 /var/www/html/votes/vendor/proengsoft/laravel-jsvalidation/src/RemoteValidationMiddleware.php(53): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Proengsoft\JsValidation\RemoteValidationMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /var/www/html/votes/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#41 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#42 /var/www/html/votes/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#43 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#44 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#45 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#46 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#47 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#48 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#49 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#50 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#51 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#52 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#53 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#54 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#55 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#56 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#57 /var/www/html/votes/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkMiddleware.php(29): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#58 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Clockwork\Support\Laravel\ClockworkMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))
#59 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#60 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#61 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#62 /var/www/html/votes/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#63 /var/www/html/votes/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#64 {main}
"}
Casn something be found in this error text?
It breaks my mind why try { block does not trigger...
For the update of my post table I want to add a validation to check if an image was uploaded. If no image is uploaded, everything is uploaded except the image, else it means there is an image and that is update.
I tried this in my Controller:
public function update(Request $request, $id)
{
if(request('photo')){
$exploded = explode(',', request('photo'));
$decoded = base64_decode($exploded[1]);
if(str_contains($exploded[0], 'jpeg'))
$extension = 'jpg';
else
$extension = 'png';
$fileName = str_random().'.'.$extension;
$path = public_path().'/'.$fileName;
file_put_contents($path, $decoded);
$post = Post::findOrFail($id);
$post->title = request('title');
$post->description = request('description');
$post->category_id = request('category_id');
$post->user_id = Auth::id();
$post->photo = $fileName;
$post->save();
}
else{
$post = Post::findOrFail($id);
$post->title = request('title');
$post->description = request('description');
$post->category_id = request('category_id');
$post->user_id = Auth::id();
$post->save();
}
return response()->json([
'post' => $post,
], 200);
}
In my vue file I have the following:
editPost(){
if(this.update_post.photo == ''){
axios.put('/api/posts/' + this.update_post.id, {
title: this.update_post.title,
description: this.update_post.description,
category_id: this.update_post.category_id
})
.then(response => {
alert('updated');
this.showPosts();
})
.catch(function(error){
console.log(error);
});
}
else{
axios.put('/api/posts/' + this.update_post.id, {
title: this.update_post.title,
description: this.update_post.description,
category_id: this.update_post.category_id,
photo: this.update_post.photo
})
.then(response => {
alert('updated');
this.showPosts();
})
.catch(function(error){
console.log(error);
});
}
}
When I try to update a post, if no image is inserted I get 500 Internal server error:
app.js:14233 PUT http://myblog.local/api/posts/52 500 (Internal Server Error)
The below are some of the errors I see in the error log:
[2018-06-27 20:55:48] local.ERROR: Undefined offset: 1 {"userId":11,"email":"sidney#lab.com","exception":"[object] (ErrorException(code: 0): Undefined offset: 1 at C:\\xampp\\htdocs\\sidneyblog\\app\\Http\\Controllers\\AdminPostsController.php:66)
[stacktrace]
#0 C:\\xampp\\htdocs\\sidneyblog\\app\\Http\\Controllers\\AdminPostsController.php(66): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined offse...', 'C:\\\\xampp\\\\htdocs...', 66, Array)
#1 [internal function]: App\\Http\\Controllers\\AdminPostsController->update(Object(Illuminate\\Http\\Request), '53')
#2 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php(54): call_user_func_array(Array, Array)
#3 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('update', Array)
#4 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\AdminPostsController), 'update')
#5 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php(169): Illuminate\\Routing\\Route->runController()
#6 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(665): Illuminate\\Routing\\Route->run()
#7 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#8 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#9 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#10 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#11 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken.php(67): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#12 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#13 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#14 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#15 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#16 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#17 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php(63): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#18 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#19 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#20 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#21 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#22 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#23 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php(59): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#24 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#25 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#26 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#27 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(667): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#28 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(642): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#29 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(608): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#30 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php(597): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#31 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#32 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#33 C:\\xampp\\htdocs\\sidneyblog\\vendor\\fideloper\\proxy\\src\\TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#34 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#37 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#38 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#40 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#41 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#42 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#43 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#45 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php(51): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#46 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#47 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#48 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#49 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#50 C:\\xampp\\htdocs\\sidneyblog\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#51 C:\\xampp\\htdocs\\sidneyblog\\public\\index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#52 {main}
"}
How can I fix that?
In your controller, the condition if(request('photo')) is always true.
To Retrieving Input from the request use Request $request variable. for example:
for file: $request->file('photo');
for other text: $request->input('description');