I am using a custom server with nextjs to inject some serverSideProps / getInitialProps into files. What I am doing is having something on the server update a json file every minute or so and then the getServerSideProps/getInitialProps functions read the json file from disk to populate data quickly (without having to do a network request for data).
Everything works great in localhost and when doing a build/running the build locally. In production / after deploying to vercel i get the error: Internal Server Error when trying to open a page. Vercel offers build logs but not any logs for the running custom server.
Is this likely a problem to do with unable to write to disk in the vm's that vercel uses to deploy apps?
Is there an example out there of how I can read/write to disk with a custom server in nextjs for this purpose?
Vercel is a serverless platform and doesn't support a custom server.
If possible, you can migrate away from the custom server (with API routes) or consider other hosting options.
Next.js Deployment
Related
I have an app that builds with Vuejs and Nodejs server.
I created a folder called 'uploads' in the project to temporary store all of the files that was uploaded to the server.
When the uploaded action is ready, I have a restAPI to clean the file in folder 'uploads' with the given absolute path. I use fs.unlinkSync to remove the temp file in the rest api.
Everything works perfectly on local, but after I deploy to azure web app, whenever the restapi for removing a file is triggered, it gives me 502 bad gateway error.
I have checked a lot of information, still can not solve this problem. Wonder if anyone have experience with it?
Log from Azure Web App
Failed to forward request to application. Encountered a System.Threading.Tasks.TaskCanceledException exception after 300196.724ms with message: The operation was canceled.. Check application logs to verify the application is properly handling HTTP traffic.
Try to use fs.unlink(path, callback), then you can log more error details in callback function.
Suggestion
You also can use try..catch... to get more exception message. Get error details should be useful to you to solve the problem.
About Log from Azure Web App, I'm not sure how you use it, or use the default. The exception caught by the code may be more helpful to you.
If you use linux platform, you can use remote debugging.
Azure Remote Debugging for Node.js
I have created a simple todo app for learning purposes. It is a full stack website that consists of a static html file with js script that is accessing api on the same host. Backend is build on node.js with express framework and mongodb. Everything works fine on a local server, that I start with cmd:
firebase serve --only functions,hosting
However when I deploy the app to the firebase cloud with cmd:
firebase deploy
I cannot access JSON file that should be served under /api/todos. Instead I receive 503 error:
The app/api/todos also does not work and gives error: Cannot GET /app/api/todos
I can access the file locally:
How can I access my JSON file after the deployment? How the route /app/api/todos would be translated in the app that is deployed?
You should rewrite your /api route from hosting to functions in firebase.json file
Take a look to this link
Problem: after deploying my asp.net core web api to azure app service I can't get a response from the expected endpoint
Steps followed:
I have an api that works fine when serving from my local machine, developed using Visual Studio Code. (The code for that is here https://github.com/samrae7/blog-api FYI)
I followed the instructions in this video: https://www.youtube.com/watch?v=C8J_CRy2_XA to push the files up to Azure App services. Basically I used the VS Code azure app service extension to create a webapp on azure and push my files.
I can see my files have been pushed to Azure ( by logging in to the portal and looking) but when I navigate to the expected URL of my api, http://sams-blog-api.azurewebsites.net, I get 'site not found'. If I try to send a request to the expected endpoint (I append /api/resource as this is the path of the endpoints on my local machine) I get '404 not found'
So my question is what do I have to do to actually get my api up and running online after pushing the files to azure app service
Thanks
Your website is not accessible due to missing DNS entry. I check it using the mxtool
https://mxtoolbox.com/SuperTool.aspx?action=a%3asams-blog-api.azurewebsites.net&run=toolpage#
Please ensure that your url is correct.
The basic answer to this question was that I had not understood that you have to create a Database in azure for your deployed app to connect to, and you need to set the connection string as an env variable in azure so that it knows where to look, and you should also add code that automatically updates the database on launch.
This tutorial was what helped with that: https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-dotnetcore-sqldb
I then hit another issue where the deployed app was still returning a generic 500 server error. By enabling 'Diagnostic logs' via the azure portal, and downloading the logs, I saw this detailed error: The configuration section 'httpProtocol' cannot be read because it is missing a section declaration referring to a piece of config in my Web.config. I deleted it (I don't need it for now) and that fixed the issue
I successfully deployed my Vue app using Firebase hosting except for one small thing - the database that I was running from localhost isn't appearing / being referenced when I navigate to the hosting URL (https://.firebaseapp.com.
Instead, any changes I make in attempt to recreate the data on the hosted site only effects my instance running on localhost!
Basically:
Why am I not seeing any db data once i deploy using the standard firebase commands firebase init and firebase deploy?
When I deploy how can I use the same database from localhost but have it running as a copy so that the deployed database and localhost database are kept separate?
I answered the first part via changing how I was deploying. Screenshot is attached.
I answered the second part through this post
All static files are hosting on CDN how Firebase make sure the most recent version of index.html file is fetched when the user made a network request?
Does this process involved with Nginx or something similar?
What's the process behind this One-click rollback?
When you deploy a version of you app/site, all the resources of your site/app are bundled up and sent to Firebase Hosting's servers. Firebase validates that the files are intact and then tells the CDN to flush its cache. The next time that an edge cache in the CDN receives a request for a file from your app/site, it requests that file from the Firebase Hosting origin servers.
The rollback of Firebase Hosting is quite similar to what happens when you deploy a new version of your site/app. Firebase Hosting takes the old bundle and essentially deploys it. From there the process is the same.