Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact form not working #45

Open
asd1495 opened this issue Nov 15, 2022 · 5 comments
Open

Contact form not working #45

asd1495 opened this issue Nov 15, 2022 · 5 comments

Comments

@asd1495
Copy link

asd1495 commented Nov 15, 2022

Messages are not posted to sanity and two errors are shown:

Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component.

Object { response: {…}, statusCode: 403, responseBody: "{\n "error": {\n "description": "Mutation(s) failed with 1 error(s)",\n "items": [\n {\n "error": {\n "description": "Insufficient permissions; permission \"create\" required",\n "permission": "create",\n "type": "insufficientPermissionsError"\n },\n "index": 0\n }\n ],\n "type": "mutationError"\n }\n}", details: {…}, stack: "", … }

details: Object { description: "Mutation(s) failed with 1 error(s)", items: (1) […], type: "mutationError" }

message: "Mutation(s) failed with 1 error(s)"

name: "ClientError"

response: Object { url: "https://e3htzv4z.api.sanity.io/v2022-02-01/data/mutate/production?returnIds=true&returnDocuments=true&visibility=sync", method: "POST", statusCode: 403, … }

responseBody: "{\n "error": {\n "description": "Mutation(s) failed with 1 error(s)",\n "items": [\n {\n "error": {\n "description": "Insufficient permissions; permission \"create\" required",\n "permission": "create",\n "type": "insufficientPermissionsError"\n },\n "index": 0\n }\n ],\n "type": "mutationError"\n }\n}"

stack:

statusCode: 403

@hafizn07
Copy link

Did you found the solution for this??

@hafizn07
Copy link

403 means you are not allowed to mutate. You need to check the authorization part of the app on the backend where visitors do not have access to send requests.

Check and make sure you token is in editor mode.
and run the project once again

@asd1495
Copy link
Author

asd1495 commented Dec 28, 2022

403 means you are not allowed to mutate. You need to check the authorization part of the app on the backend where visitors do not have access to send requests.

Check and make sure you token is in editor mode.
and run the project once again

Thanks for the advice, I'm gonna try to fix asap and let you know if it works!

Edit: Token is already on editor mode but the error is still there

@npmRunTheWorld
Copy link

So this is an issue with the .env file. Basically, during the development process, the .env file for some reason returns undefined. You can take your token and project id, and production and just put it all in the client.js file without the process.env.React_App_.. When it's time to build and deploy that's when you should put those env variables back into the client for production.

Since this is a problem with the .env files a few solutions if this is happening during development are. 1) Make sure the .env file is in your root directory and not in your src directory. 2) make sure within your .env file there is only the token or id without the quotations, commas, etc. just the keys alone. 3)Restart the npm server and if that doesnt work then close vscode and restart again.

@monis07
Copy link

monis07 commented Mar 18, 2024

@acej0k3r I was facing the same issue and issue got resolved when i put the token inside client.js file instead of .env. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants