I am new to web development and even though i have looked around I am still stuck with this part which is to manage to make my api run on a server. Locally it runs perfectly but once I add my api inside my server it just says not found whenever i attempt to access it.
This is the folder structure
-www
--wp-admin
--wp-content
--wp-includes
--ProjectApi
---app
---bootstrap
---config
---database
---public
----index.php
----.htaccess
---resources
---routes
---storage
---tests
---vendor
Locally i would just say http://localhost/ProjectApi/public/api/v1/hello and this would call my api and do its function. But once it was added to the server when i do http://randomServerName.com/ProjectApi/public/api/v1/hello It just gives me a 404 not found error.
Related
I'm trying to deploy a Next.js app to Vercel, it's a portfolio with only one page(index) and a couple of API routes. Vercel dashboard displays that the deployment is successful but when I visit the app it displays the layout component(the navbar and the footer but some styles are lost) with a 404 page like the attached image. I tried to deploy with getStaticProps and with getServerSideProps and ended up with the same result. The API routes are working fine though both in SSG and SSR, I can retrieve the data from them weather from the browser or postman for example. I've been searching for a while now and this issue here is the most relative one to mine, but I tried all solution mentioned in it and non of them worked for me. I made sure that the framework preset is next.js and that the root directory is correct, the app isn't served through a sub directory. Also I'm using a variable for the domain name stored in the .env file, I tried to deploy and leave it as the default(localhost:3000) and tried to change it to on of the vercel auto assigned domain names and tried to add the variable from the project settings on vercel, and also tried to deploy without it at all and all the scenarios leaded to the same result(the 404 page and the APIs are working fine). This is the first time I deploy on vercel, I tried to contact them but I received no answers, I guess because I'm on a hobby tier. This is the project repo. The app works fine in development and also when I build and start the server locally.
The issue is that you're calling internal endpoints (e.g. functions on api folder) in getStaticProps. This is a Next.js anti-pattern (More about this on the docs). The reason being is that getStaticProps fetches the necessary data required to build the static page on build-time, but at this point of the process, the serverless functions contained on the api folder have not been deployed yet. You're getting a 404 page because you are using a try/catch block in getStaticProps, so when axios throws, catch block takes the control and returns notFound: true.
I am trying to deploy my MERN stack application to a server using AWS-EC2. Though everything seems to be working when I try and make API calls I get weird non-json returns which destroys all functionality.
I think I read that the reason this may be happening is that Nginx doesn't work with static pages, but when I tried using the non-static page (client/public/index.html as opposed to client/build/index.html), the page just renders black, and the inspecting element shows there is nothing in the body.
Is there any workaround or alternative solution?
Here is what the API returns using the server port created with Nginx:
Here is it working perfectly fine locally on my machine:
I know the VS Code is the tool most seen in Angular demos and I've tried them but I was going through a YouTube demo on using Visual Studio to develop a Hello World Angular app.I started out using NPM START to run the app then was following the instructions here to use the Visual Studio Start button to initiate the app.
The app was sometimes rerunning and sometimes not. I was thinking it had something to do with the startup folder but now I wish that I would have modified by startup page instead.
Here's what my folder structure looks like:
Anyways, I first I started messing with the application root URL. I tried changing it from
http://localhost:61539
to
http://localhost:61539/src
and some other values too. I confirmed that i wanted to create a virtual folder and played around entering multiple values. As a result, I noticed that my IISExpress icon in the tray started to show all of the URLS that I had entered
I wanted to try an undo these virtual folders that I created but I didn't know where they were stored. Finally, I saw that the last path that I specify is stored in the VS Project file but I don't know where all of the other sites are stored. I'd like to delete them. Is there some IIS Express config file?
The whole problem started when I was trying to get the initial the web page to come up and I was getting a "Forbidden" error. Now I think that it could possible be solve by setting my initial page to src/index.html, although the YouTube video didn't mention it.
Now, every time I hit the start button to run the web app, the following URL is displayed with an extra trailing slash after the html page name.
http://localhost:61539/src/index.html/
and I still get the forbidden error.
Question
So, how do I clean up my IIS Sites that I don't need and set my startup params so that the web page comes up and displays index.html?
I've done a lot of searching and not found anything like this, but I might not be using the right terms. My problem is this:
On a Tomcat 6 server, I originally deployed a Spring Webflow app with a context root of fred - to access it people went to myserver.com:8080/fred
The Spring code in that app changed all requests to have /spring after the context root - so the URL above would become myserver.com:8080/fred/spring - and this would bring up the index page.
That was all fine & dandy.
I rewrote the app to use Spring MVC instead, for reasons too boring to mention here, and as part of this removed the code that performed the /spring piece.
I am now trying to deploy it to the same Tomcat instance. It appears to deploy fine (after undeploying the old one).
However when I try to hit myserver.com:8080/fred to get the index page, it redirects to myserver.com:8080/fred/spring, and naturally this fails as that URL is not supported.
I've checked my config within the WAR, and also scanned through the following places in Tomcat:
conf directory
conf/catalina and subdirectories
webapps and subdirectories
work and subdirectories
I can't see anything referring to this /spring url rewrite. It does deploy and work successfully on my local version of Tomcat.
Could anyone offer any suggestions? All help is appreciated.
Sounds like your browser cached the redirect. If your site at myserver.com:8080 used hard redirects (301 Moved Permanently) to send users from /fred to /fred/spring your browser will remember that the next time you access the application. Try emptying the browser cache and trying again.
That would explain why everything is dandy on your local machine
I uploaded an app to babble.meteor.com, but when trying to insert a record from the client, I'm getting the following error:
Messages.insert({name: "lol", text: "hey there"})
"656bffcf-7046-4cce-b460-5441195680ae"
POST http://babble.meteor.com/sockjs/074/ohxs7fj4/xhr_send 404 (Not Found)
The application works fine locally and on my intranet.
Here's the code I have defining Messages (runs on both client and server):
Messages = new Meteor.Collection("messages")
Edit:
The POST seems to be going through now, but when I inspect the server-side database, the records aren't actually being inserted, only updated on the client. So when I refresh the page, I've lost all the messages that were inserted on the client. What's going on?
Edit 2:
Looks like this is only a problem for [app].meteor.com, because I pushed my code to a Heroku app and it works fine.
Do you mean you see this POST error on the web developer console? This probably means your server restarted for some reason, and your client had to reconnect. This is not necessarily a problem, reconnections to a new server are rare, but do happen.
However, it might mean there is an error in the server code and your application is crashing. Check your logs with 'meteor logs [app].meteor.com' to inspect for problems.
Looks like it was an [app].meteor.com problem. Deleting and redeploying the app worked fine.
$ meteor deploy --delete [app].meteor.com
$ meteor deploy app.meteor.com