[SOLVED] Can't send requests to NFT API without the user connecting

Hello,
Since switching to a Moralis self-hosted server, users can no longer view any API data without connecting via metamask and signing for Moralis. Its being used for an NFT Marketplace so it is important that users can view listings and NFT data without even having Metamask installed.
When Iā€™m not signed in I just get error ā€œunauthorizedā€, but when I sign in, everything starts to work again.

Screenshot_4 Screenshot_5

This seems to be related to the application id being sent or not in those requests.
You can try to authenticate them with a default user that has username and password

This is the code thatā€™s causing errors. If I authenticate, then it starts to work. But I need it to work both ways.

const options = { address: address, chain: Data.MoralisChain };
const NFTs = await Moralis.Web3API.token.getAllTokenIds(options);

Iā€™ll ask the team. I donā€™t know other easy fix now.

1 Like

This is what I use for App initialization
Screenshot_7
And I when I manually sign in, it starts to work.

Alternatively you can try to make a request with axios to get that info when the user is not authenticated. You can look in network tab to see the parameters and skip the session id that is specific to an authenticated user

Hi there, i think it should be an easy thing to patch for the team, we will get back!

1 Like

Thanks, please inform when fixed <3

Any news on this? This issue still exists.

we have a PR ready for this fix, you can also use this solution meanwhile:

1 Like

now you can also use to SDK v1.12.0

Canā€™t seem to find any SDK with v1.12.0, could please provide more info.

this was the PR

Updated the SDK but for some reason the same issue still persists.
The error only exists when I use the local Moralis server.

It seems to work when fetching data from DB, but stops working when I call a function like getTokenIdMetadata.

The second I switch back to the remotely hosted server, everything starts working again.

Did you thy that patch to add that app id?

Faced way to many errors trying to setup express. Too many changed required to make that patch work for me.

You only have to change in a file locally

Get the error 'app' is not defined. What am I doing wrong here? Followed the exact instructions from the patch.

Screenshot_13