Supabase Type Generation Not Working as Expected

Every time I try to update my typing through the cli command, I keep getting this error message without much information for me to troubleshoot.

2023/03/01 09:34:01 Recv First Byte
Error: failed to retrieve generated types: {"message":"Forbidden resource"}

Here is the command I am running:

 npx supabase gen types typescript --project-id "$MY_ID" --schema public > types/supabase.ts --debug

If anyone has encountered this error before, please share your insights. I have used this command successfully in the past, but now it seems to be causing issues.

Answer №1

If you are facing issues with the following error message:

Error: unable to fetch generated types: {"message":"Access to resource denied"}

Double check that when entering your command, you specify the --project-id as the Reference ID of the project, not the project name.
You can locate your Reference ID in Project -> Settings -> General.
The Reference ID typically appears similar to: lbacalnbzxalbglalphsblxl

Answer №2

The problem originated from being signed in to an alternate supabase account using the supabase access token. Ensure that you are logged in to the accurate supabase account through the supabase cli and utilizing your valid access token.

Answer №3

Follow these steps:

  1. Launch the command: "supabase login"
  2. Input your unique access token
  3. Attempt to accomplish your original goal from this point...

Answer №4

Double check that the text program where you stored your note (yes, Apple Notes, we're looking at you) hasn't altered any characters

#fails because of a missing -- and incorrect quote character “ instead of "
npx supabase gen types typescript —project-id “MYID”

is different from

#will succeed
npx supabase gen types typescript --project-id "MYID"

Answer №5

If you're looking for a solution to this question, here are some helpful tips for creating types:

1). Ensure you have the supabase CLI installed and have authorized after generating the Access token on your dashboard.

2). Once authorized, if you're using NextJS, create a database.types.ts file in the root of your project.

3). Use the following command in the terminal: npx supabase gen types typescript --project-id "*project_id" --schema public > database.types.ts

Remember to replace *project_id with your actual project ID, which can usually be found in the supabase URL for your project.

If you want to learn how to set up Github Actions to update your database types at specific times, check out the supabase docs at

I hope these tips will be useful to you

Answer №6

After much research and experimentation, a breakthrough has been made!

  1. Create a new folder called 'type' in your main directory
  2. Next, within the 'type' folder, create a file named 'supabase.ts'

Execute the following command to implement the solution.

npx supabase gen types typescript --project-id "$PROJECT_REF" --schema public > types/supabase.ts

Answer №7

Encountered a similar problem. It appears that when using WSL, the supabase login command fails to save the token generated during the authentication process. Here's how I resolved it:

  1. Created the token manually in the "Account > Access Tokens" section
  2. Copied the newly generated token
  3. Pasted the token into the command line and ran
    supabase login --token [pasted_token]

Following these steps, I was able to successfully generate the necessary types from the command line interface.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing the target to malfunction in this situation?

Initially, I create an index page with frames named after popular websites such as NASA, Google, YouTube, etc. Then, on the search page, <input id="main_category_lan1" value="test" /> <a href="javascript:void(0)" onmouseover=" window.open ...

In Typescript, which kind of event is suitable for MouseEvent<HTMLDivElement>?

My goal is to close the modal when clicking outside the div element. Take a look at my code below. // The onClose function is a setState(false) function. import { useRef, useEffect } from 'hooks' import { MouseEvent } from 'react' imp ...

"Executing a query on Angular Firestore using the where clause fetches all documents from the

I am encountering a perplexing issue with my angular app that is connected to Firestore. Despite following the documentation closely, when I query for documents in a collection based on a specific condition, the array returned contains every single documen ...

Assistance Required in Turning Down Trade Requests on Steam That Involve Losing items

Currently, I have a code snippet from a Steam bot that processes incoming trade offers by accepting or declining them based on their state. However, my goal is to modify it in a way so that it automatically accepts trade offers where I receive items, but ...

Alternative for using useRouteMatch to retrieve parameters

I'm currently refactoring this code and struggling to find a suitable replacement for this section. This is due to the react-router-dom v6 no longer having the useRouteMatch feature, which I relied on to extract parameters from the URL: import React, ...

Beginner with webpack encountering autoprefix issues while using webpack manifest plugin

My attempt to use the webpack manifest plugin to create a manifest.json file containing keys and values for my assets with contenthash in their names has hit a snag. The issue is that the values in the manifest file have the prefix "auto" attached to them, ...

How can I trigger an Onclick event from an <a tag without text in a Javascript form using Selenium?

Here is my original source code: <a onclick="pd(event);" tabindex="0" issprite="true" data-ctl="Icon" style="overflow: hidden; background: transparent url("webwb/pygridicons_12892877635.png!!.png") no-repeat scroll 0px top; width: 16px; height: 16px ...

The function Model.find({}) is coming back as empty despite the fact that there are records present in the

While I can successfully add data to the users collection using my '/sign-up' route, I'm facing an issue with reading all the documents from the users collection. Instead of the expected data, all I receive is an empty array. { "status": ...

The Vue.js Vuetify.js error message is saying "A mystery custom element: <v-list-item>, <v-list-item-title> - Have you properly registered the component?"

I followed the instructions from Vuetify Data Iterator Filter section I am able to use various Vuetify components like v-btn, v-card, v-data-table, v-data-iterator, and more. However, I encountered errors only with <v-list-item> and <v-list-item ...

Adjust object values dynamically with TypeScript by identifying the corresponding keys

Currently, I am in the process of creating a function in TypeScript that will return another function allowing me to modify the keys of an object. This specific function is intended for use within a React reducer. For instance, if I have a state object wi ...

Having difficulty fully modifying the jQuery class

My goal is to create an emoji system using a file named emoji.css to store the emojis. The names of the emojis are stored in a JavaScript array with some modifications. When users input an emoji text like :emoji: or :another-emoji:, JavaScript should check ...

"Provide information, then open a new webpage by clicking on a button. Perform various actions with the form by using type

Is there a way to quickly submit form entries to my database and then automatically redirect to a new page? My current situation requires that submitted information is stored in the DB before directing users to a thank you page, all in one seamless click! ...

Utilizing Angular's File Upload feature with Glyphicon icons

Has anyone tried to open a local file using bootstrap glyphicon? I found this example at https://jsfiddle.net/JeJenny/ZG9re/, but it doesn't seem to work. Does anyone have any ideas on how to make this approach work with images like glyphicon? main.h ...

jQuery click event handler performing no action

I am encountering an issue with the input on my index page: <input type="button" name="goReplaceAll" value="Go" id="allReplaceGo" style="cursor:hand;" /> There is an onclick call from jQuery as follows: $(document).ready(function() { $(&ap ...

`Managing select tag data in Angular reactive forms`

Having an issue with selecting the gender option from JSON formatted data received from the backend. The gender is displayed as a select tag on the frontend, but it does not pre-select the option that corresponds to the gender value in the JSON data. The b ...

What is the best way to initiate a change event using JavaScript?

I am attempting to enable my 4th checkbox automatically when there is a new value in the textbox (myinput). If the textbox is empty, I want to disable it. Currently, you have to tab out before the change event is triggered. Also, how can I check for an e ...

Extract particular information from the JSON reply

When working with a JSON response in JavaScript, I use the following code to convert it to a string: var myObject = JSON.stringify(data); Although this code successfully prints out the results, I am having trouble extracting specific data such as myObjec ...

What is the trick to make the "@" alias function in a Typescript ESM project?

My current challenge involves running a script using ESM: ts-node --esm -r tsconfig-paths/register -T src/server/api/jobs/index.ts Despite my efforts, the script seems unable to handle imports like import '@/server/init.ts': CustomError: Cannot ...

What is the process for importing the TokenExpiredError that is thrown by the verify function in jsonwebtoken?

Is there a way to determine if an Error object thrown by the jwt.verify function in the jsonwebtoken library is of type TokenExpiredError using Typescript's instanceof? For example: import jwt from "jsonwebtoken"; function someFunction() { try { ...

Is this filter selector in jQuery correct?

It appears to function correctly, but I am unsure if there is room for improvement. I aim to target any HTML element with a class of edit-text-NUM or edit-html-NUM and adjust its color. This is the code snippet I am currently utilizing... jQuery(document ...