The app works perfectly fine in the development environment. After updating the .env file and deploying it on the server the app should work fine in the production environment as well.
Actual behavior
But I receive the following CORS error when I try to open the app in the production environment.
I was thinking of if you were able to ping your server or not, which you just did successfully.
The CORS issue you’r facing is probably due to a misconfiguration on a header sent with the request. Can you please share to me the request & response header of the failing request?
Thanks lclisson. I have updated the corsConfig which you have shared and the CORS issue has been resolved and the issue is no more reflecting in the console.
But I am seeing a strange thing in the console. I have updated the production link in forestadmin dashboard as well as in the .env file as the production app link. But still, in the console authentication, the API is getting hit on the localhost URL. I guess if we resolve that the app should start working.
Following is a screenshot for reference:
And following is the response: {"errors":[{"status":500,"detail":"Invalid response from the authentication server: the state parameter is missing","name":"Error"}]}
The format of the request sent to your server is correct and I don’t see any misconfiguration from that point of view. As there was an error in your app.js file before, can you share with me all the content of the file so I can double check everything is all right ?
Looking at the creation date of your project and the lumber version used to generate it, I can see that the generated files are not the ones you are supposed to have and it could explain the authentication issue you are having
Have you copy/paste some files from a previous project? From what I see the easiest things should be to generate a new project with the latest lumber version which you can installed by running npm install -g lumber-cli@latest -s
Thanks, team Forestadmin for the quick resolution of the issue.
As mentioned above the project was working in a development environment but was not working in production when deployed on EC2 and sending the requests via CloudFront.
The first issue was that CloudFront in its default setting that removes the query parameters and headers from the request. You need to change the setting to allow all query parameters to be forwarded with the request. For headers, you need to allow origin and authorization headers to be forwarded.