Why the API route don't work on deployment on vercel - web-deployment

Anyone can help me, the api route work perfectly on my local projet, but if I deploy on vercel, the api route don't work. Many thanks.
I want to have access to my the api route.

Related

in a nextjs-firebase app, google login works locally but not when deployed to Heroku

login modal pops up for a split second and disappears... help anyone?
tried deploying my nextjs-firebase app to Heroku, expected auth to work as it does in dev on localhost
This can be because of your firebase Auth setup, check if you're not referencing some speicific origin URLs that the Oauth works on. Maybe you're mentioning only the localhost origin, but not the domain of the deployed project.

How to deploy full-stack app to be able to set http-only cookie from backend?

I deployed frontend on netlify.com and backend on render.com, how I got I can't set cookie from backend because frontend and backend are on different domains.
I found out that I can set sameSite: none, but it makes cookie less secured.
I use two github repositories, one for frontend, one for backend. Will cookies work if I deploy frontend and backend on same web hosting (heroku for instance) as two apps? Or if I do it that way they will be on different subdomains and cookie also will not work? Can I deploy two apps on one subdomain?
Or the only way to deploy is to make repository, containing both of frontend and backend, and deploy from this repository as one app? Is it right?
Any clues and advices are appreciated :)

nextJS api routes not working with Firebase Hosting

I am having an issue with using Next.js API routes when deploying my website to Firebase Hosting. Here is the api call:
And here is the set up in the pages directory:
Here is the function used in email.js:
I changed the variables as to not give away my email address.
The call works when I use local host. However, when I build and deploy to firebase. I have tried to use the firebase url to make the api call, but I get a 404 page not found. I am not sure how to fix this. I would really appreciate any help.
Firebase hosting only hosts static files which is why your api routes don't work there. If you had a fully static Next site, you could host it on Firebase hosting. But if you want to use the api routes in Next, you need a server. One way to do this (albeit complicated) is to set up Firebase Functions with your api code and then rewrite requests in Firebase Hosting to that Firebase Function. It's complicated because it would require a fairly complex deploy process.
If the rest of your site is static, you can use Firebase Hosting for that and then consider ditching the api routes and instead setting up a Firebase Function to act as your api completely separate from Next.
Or if you want to keep it all in Next, consider something like Vercel for your site + api via Next.

Implementing Google Calendar API to get a list of events in ASP.NET core

I followed the tutorial here, except that I implemented it in a web app, and everything works fine in localhost, when I call the API to get calendar events for a give date, I get the events list back. However when I deploy to my test site I get a 502 Bad Gateway response, making the same call as in localhost.
Has anybody experienced the same? How to fix it?
If it works on localhost and not on deployment, it just means there are configurations which haven't been met. Check this Web applications (ASP.NET MVC) about setting up web apps using ASP.NET.
In order to run the following code successfully, you must first add a
redirect URI to your project in the Google API Console. Since you will
use FlowMetadata and its default settings, set the redirect URI to
your_site/AuthCallback/IndexAsync.

ASP.NET WEB API 2 Works Locally But Not On Production Web Server

I've developed a new WEB API 2 that works great locally, however when I upload the same code to my production server (Arvixe in this case) all I get is a 404 when I call it. I've spent HOURS searching the web, reading forums, etc.. and have been able to find no resolution, so I'm asking here as my last effort.
I'm currently only testing with the default project that gets created when you do New Project > ASP.NET Web API 2 Empty Project in Visual Studio. This creates an empty project with a single ValuesController. You should be able the JSON response by called /api/values, but this doesn't even work.
I'm using Fiddler to test the API locally and on the web server.
http://localhost:1993/api/values <--- works great
but
http://api.mydomain.com/api/values <--- returns 404
Note: I created a subdomain "api" in this case, but everything for the code for the API is unchanged from when it was created.
Why in the world does this work locally but not on the production web server?
That the server returns 404 (Not Found) may indicate a lot of things. However you can check using the following step:
Add a simple text document like readme.txt to your a folder sub-domain http://api.mydomain.com, and try to get access to that. If you can't access to that file, it means that the subdomain is not configured properly.
Publish the webservice using the "Publish" functionality, so that all DLLs will be copied.
After that,try to reach the Web ApI again.
Hope that help.
"Note: I created a subdomain 'api' in this case, but everything for the code for the API is unchanged from when it was created."
Above comment of your's is suspicious, you should publish your WEB API application in the root directory. Like if http://example.com is pointing to "MyExample" folder, then application should be published on "MyExample" folder.
After that you will be able access your api with http://example.com/api/{controller}/{action}
Just a simple suggestion which I'm sure you have already considered, but have you opened the http port 80 on the server's firewall?
Also stick a plain old html file in the root of your project and see if the server serves it up.
in your case, since you create a subdomain of 'api', you should try
http://api.mydomain.com/api/api/values
note that if you're using database for the function, you should change the connectionString in your web config
Please verify the .net framework on you hosted domain that may be old one.
Web api 2 is supposed on 4.5 framework.
One reason for web api 2 method working OK on local machine but not on production server is that the method you are calling is working on local machine but not on remote server. In such a case you will receive message 404 or 500, and you would be lost why this routing is failing.
Why a method would fail on remote server, well there may be many reasons. For me, I was querying database in my method and my connectionString was not set for remote server.
One way of resolving it would be to put some very simple code in that particular method and test that routing is working. Then check your original code for errors reasons.

Resources