Notification texts go here Contact Us Buy Now!

Fetch request to PocketBase fails from terminal but works in Postman and the browser | Next.js13

I wasn't able to pin point the source of the issue,

However, it seems that switching to a non-chromium based browser is a valid workaround for the time being

This is the github issue with more information about the problem

I think this is due to the behavior change in recent versions of NextJS. Check that there is a value set for the HOSTNAME environment variable. If yes and it is different from localhost, the node will not open the port on the local address (localhost) and there will be no connection through the local IP (127.0.0.1). You can test by setting HOSTNAME with the "localhost" value.

Do pb.autoCancellation(false); Disabling auto-cancellation is generally not recommended as it can lead to unexpected behavior if multiple requests interfere with each other.

check network while requesting this api. There may be multiple calls. You can learn more from here - https://github.com/pocketbase/js-sdk#auto-cancellation

isAbort: true indicates intentional cancellation by the SDK, isAbort: false can arise due to other network connectivity or server-side issues.

import PocketBase from 'pocketbase';

async function getNotes(){
        pb.autoCancellation(false);
        const pb = new PocketBase('http://127.0.0.1:8090')
        const list = await pb.collection('notes').getList(1, 100, {});
        return list;
}

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.