anything-llm
anything-llm copied to clipboard
Error: Unexpected token 'U', "Unauthorized" is not valid JSON
Get the following error when I try to create a new workspace.
Error: Unexpected token 'U', "Unauthorized" is not valid JSON
Steps
- Create a new invitation for a new user.
- In a Private window, open the invitation and signup as a new user.
- Create a new Workspace using the button in the onboarding.
Ah, it is because you are clicking on the "Create First Workspace" in the messages in the default view, but in multi user mode the creation of workspaces for users is disabled, thus Unauthorized
As an admin, if you enabled "Users can create workspaces" in settings this would not longer occur.
@timothycarambat Would you estimate this to be a Good first issue
?
I would like to take a stab at making a contribution if possible, might need some support. I love this project and see myself contributing and this might be a good place to start.
@bkowshik I think so!
In general, what needs to be check is if those buttons should display based on the user
object which can be gotten from useUser
hook. This only applies if the instance admin did not set the welcome messages to something custom.
https://github.com/Mintplex-Labs/anything-llm/blob/master/frontend/src/components/DefaultChat/index.jsx#L21
Add const {user} = useUser()
to top of component.
Then in all places there is a CTA to create a workspace in the MESSAGES
array you can change
<button
onClick={showNewWsModal}
className="mt-5 w-fit transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800">
<Plus className="h-4 w-4" />
<p>Create your first workspace</p>
</button>
to
{(!user || user?.role !== "default") && (
<button
onClick={showNewWsModal}
className="mt-5 w-fit transition-all duration-300 border border-slate-200 px-4 py-2 rounded-lg text-white text-sm items-center flex gap-x-2 hover:bg-slate-200 hover:text-slate-800 focus:ring-gray-800">
<Plus className="h-4 w-4" />
<p>Create your first workspace</p>
</button>
)}
This will show the button when no user is defined (single user mode) and if the user is defined, such as in multi-user mode, make sure the role is not default. All new users are default
when created unless otherwise specified by the admin. default
users cannot create workspaces!
@timothycarambat Can I work on this issue?
@timothycarambat Can I work on this issue?
anyone can fix this issue!
Whoever wants to work it just assign the issue to yourself so its not double-worked and somebody wastes their time :)
closed by 5172bceec3f34b10ef4e96da0a6b659ccaee1f07