project_professional_portfolio icon indicating copy to clipboard operation
project_professional_portfolio copied to clipboard

Contact form not working

Open asd1495 opened this issue 2 years ago • 5 comments

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

asd1495 avatar Nov 15 '22 20:11 asd1495

Did you found the solution for this??

hafizn07 avatar Dec 23 '22 14:12 hafizn07

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

hafizn07 avatar Dec 24 '22 07:12 hafizn07

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

asd1495 avatar Dec 28 '22 20:12 asd1495

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.

theDevJudge avatar Jan 17 '23 15:01 theDevJudge

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

monis07 avatar Mar 18 '24 18:03 monis07