I am developing my college project but the post method does not work. I am using the native fetch method to post and MongoDB as a database.
I had tried Axios as well but I got the same error.
PostForm.js:36 POST http://localhost:3000/ 404 (Not Found)
server.js
backend code
PostForm.jsx
PostForm code
please anyone tell me what is the mistake I have made.
add "proxy": "http://localhost:3000" in your React Project's package.json file , and restart your project
then in fetch method , url will /
fetch('/',{method:POST,...})
Related
I'm getting an error: "Cannot GET /main" when I access this address: "http://localhost/main"
I attach pictures of my code after ng build
I moved the created folder (named client) after ng build to the server
I hope you can help me
Thank you my code
I think your express server is not redirecting to your index.html.
You can also use the routing with hash.
More details can be found here
Angular static Base URl and routing with useHash=True
Could you share a picture of the main.component.ts please. The error occurs because it cannot find Maincomponent
I reckon the error comes because you have mispelt the main.components export.
I am new to Angular 2 and just created project using latest angular-cli (angular-cli: 1.0.0-beta.16
node: 6.7.0) on Windows machine. I was trying to call my back-end server REST API in one of angular service, but it could not route my request from localhost:4200 to localhost:8080/dz/api/...
I read about proxy To backend support in angular-cli document and followed the same steps. I do have now proxy.conf.json file at package.json file level.
{
"/rest": {
"target" : "(http)://localhost:8080/dz/api/v1",
"secure" : false
}
}
and I have updated package.json file with
"start": "ng serve --proxy-config proxy.conf.json",
and then on command prompt - npm start
But, when I call the service, it does not send request to back-end server and instead throws error with 404 (not found error - (http)://localhost:4200/rest/home/list).
I would appreciate if someone can help me out here what am I doing wrong here. Am I missing any other setting? I am new to Angular 2.
I did use http-proxy-middleware when I was working with angular1.3 and it was working fine.
Thanks.
I get the following errors in a starter project with angular2, angular-cli#webpack and primeng. The only ui component from PrimeNG is a dropdown which renders and it has its values but no css theme is applied ever.(see errors below in regards to CSS). I am not sure why I get this error and have spent countless hours with no result so I am at a loss at this point. Component was generated with ng command and ng serve runs the web server. Anybody any idea? I also have tried both node.js 6.5.0 and 4.5.0 (switching and managing them with nvm).
Any help is appreciated deeply.
Failed to load resource: the server responded with a status of 404
(Not Found)
http://localhost:3000/node_modules/primeng/resources/primeng.min.css
Failed to load resource: the server responded with a status of 404
(Not Found)
http://localhost:3000/src/app/resources/css/font-awesome-4.6.3/css/font-awesome.min.css
Failed to load resource: the server responded with a status of 404
(Not Found)
http://localhost:3000/node_modules/primeui/primeui-ng-all.min.css
Failed to load resource: the server responded with a status of 404
By the way now I posted the code in: https://github.com/GregHila/primeng-angular-cli.
Under the src/ there should be a file styles.css. I think you can import the styles here.
Eg.:
#import '../node_modules/primeng/resources/primeng.min.css';
The other way is to mention them in the angular-cli.json file in the styles array.
If you are using the webpack branch, then node_modules will not exist in the served directory. You will have to import the libraries you want to use, which will cause webpack to bundle them for you. Alternatively modify apps[0].scripts and apps[0].styles properties of angular-cli.json like in https://github.com/angular/angular-cli#global-library-installation.
Seems like 1.0.0-beta.11-webpack.9-4 has also fixed the bug
I am getting a super unhelpful message 'Cannot GET /' printed to my browser when I run my node dev server through webpack. I am building a Vuejs application with the following:
VueJs structured in a way that was dicated by this Vue Template with my node scripts being identical to the default commands
Webpack config based on Vue Loader
Routes handled through Vue Router
I know this is not a great deal to go off but an idea of what is firing this error (Node? Webpack? Vue Router?) it would point me in the right direction and be greatly appreciated.
If you're experiencing this with Vite, make sure you ran just vite in your package.json script, NOT vite preview
I found myself in the same problem. In my case it was related to the use of Express with Vue.js. So I am leaving my solution in case anyone finds it useful
I added this code for handling the calls to my index.html file
app.route('/*')
.get(function(req, res) {
res.sendFile(path.join(__dirname + '/dist/index.html'));
});
module.exports = app;
Node is throwing the error and make sure your vue router is configured properly,Cannot GET simply means you have not assigned a view to your url e.g on express we use
app.use('/', your route)
and on connect we use
app.get or app.post
All it's saying is there is no content/view assigned to that url.
It turns out it was an issue with the vuejs webpack template I was working from: https://github.com/vuejs-templates/webpack
The build path was being used in the dev server configuration.
Made this pull request to fix the issue: https://github.com/vuejs-templates/webpack/pull/188#issuecomment-230968416
I had this issue while running my app in dev. Adding this to the devServer of my webpack.dev.config file helped:
historyApiFallback: true
Answer by Jezperp here.
If you are using express check that you have this line:
app.use(express.static('static'));
And that "static" matches with the folder specified in your vue.config.js
outputDir: path.resolve("../Server/static")
I met this in Node CMS KeystoneJS's admin UI, but I think this does not matter with keystone, looks like the '/' root router can not work properly in my MAC.
Here is the message I got:
GET /keystone//keystone/categories 404 17ms - 276b
GET /keystone/categories 200 615ms
The full URL is: http://localhost:3000/keystone//keystone/categories
This can work perfectly in windows, but cannot work in OSX, no matter what browser.