REST API application does not work on domain - javascript

I moved my REST API web app to registered domain. On localhost is working as intended, however when deploying to server I get following error
Failed to load resource: the server responded with a status of 404 ()
I use JS to access REST API.
Localhost http://localhost:8080/EB-Software/apii/user-form/retrieve worked perfectly, whereas http://eb-software.uk/EB-Software/apii/user-form/retrieve leads to error above.
Please help

Update the URL like this, just remove EB-Software
http://eb-software.uk/apii/user-form/retrieve

Related

Failed to load resource: the server responded with 404

I can't solve my script problem. I have tried deploying my application on render.com however i keep getting this error for all of my javascript files. the application runs perfectly when I use VS Codes live server but once deployed this error appears. I would really appreciate if someone was able to help me resolve this issue. I have also linked images.
JS:
<script type="module" src="/public/JS/setupCart.js"></script>
<script type="module" src="/public/JS/app.js"></script>
Error:
setupCart.js:1 : Failed to load resource: the server responded with a status of404 ()
app.js:1 : Failed to load resource: the server responded with a status of404 ()
Live link to application here: https://guided-fashion.onrender.com
Github repo: https://github.com/ddelimond/Guided-Fashion
In similar, kind of scenario I would suggest you to do
Viewpage source (ctrl+U) while on your local where it is working fine.
Ctrl + click the app.js and setupcart.js link on your website and look at t
their address on the address bar of your browser.
Do the similar thing on your hosted application and compare the both
addresses and see if the folder exists on the both cases.

Failed to load resource: the server responded with a status of 400 () using MongoDB atlas react site

Looking for trouble shooting ideas.
React app works perfectly on my local host but after being deployed it gives me the above error of
Failed to load resource: the server responded with a status of 400 ()
when I go to create a user, and yes I have all ips white listed in atlas. All I could think is that its an issue with my API, but wouldnt it have not worked locally if that was the case?
site in question - https://badbank3.herokuapp.com/#/CreateAccount/
I just tried it and it works perfectly fine, though you get a 400 from firebase if :
email is badly formatted ex: space at the begining or like test#gmail
you have a password shorter than 6 chars
you have no name

Http request error with codeSandBox (React/Node)

I have strange error in online IDE like CodeSandBox/StackBlitz.
I do a sample http request (with axios but with fetch or others the problem is the same) and try to print the response in the console.
I use React for the front and node (listen port 8080) for the back,
I precise that work when I do exactly the same with create react app, using npm start (localhost:3000 and http request in http://[public ip]:8080/coucou)
react code here (request is in the Main.js file):
https://codesandbox.io/s/ww28ry45pl
When I just put http://[public ip]:8080/coucou that work to and I have the good response from server.
Here the error returned by server in codeSandBox (captured by the catch bloc) :
Error {stack:
"createError#https://ww28ry45pl.codesandbox.io/node_modules/axios/lib/core/createError.js:16:15
handleError#https://ww28ry45pl.codesandbox.io/node_modules/axios/lib/adapters/xhr.js:87:14
"}
I haven't found anything about this problem.
This is because you are making an HTTP call from a secure communication point (codesandbox). You can simply use/add https on your public URL and it shall work. HTTP Ajax Request via HTTPS Page
In my case I was calling Localhost from codesandbox in https. I solved it by Enabling CORS handling on my localhost server.
Just try again without http:// prefix in the URL. I solved same error :)

jquery FullCalendar returns http 403 error

I have integrated jquery FullCalender2.2 in my php website. It is working fine with localhost but when I upload it online in my url "http://iamfortesting.com" it returns 403 response. Please help as I am unable to get the issue. Console Log is given below-
Failed to load resource: the server responded with a status of 403 (Forbidden) http://iamfortesting.com/......../fullcalendar.css
same is for fullcalendar.js also.
better you use cdn
//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.2/fullcalendar.min.css
//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.2/fullcalendar.min.js

Ajax request works in remote server but not in local server (with Codeigniter)

I've a web application wich makes Ajax requests to a server with Codeigniter-php code. The Ajax requests work correctly in local server but not when the application is hosted in remote server.
The console errors are:
XMLHttpRequest cannot load http://localhost/CI-example/index.php/control/controlHome. Origin http://www.page.com is not allowed by Access-Control-Allow-Origin.
Surprisingly, the request is made in the server but not the response.
The URL that I use to Ajax request is:
AJAX_URL = "http://localhost/CI-example/site/index.php/control/controlHome";
But, also I've tried with:
AJAX_URL = "http://www.page.com/CI-example/site/index.php/control/controlHome";
And the next error is captured:
POST http://www.page.com/webdom/site/index.php/control/controlHome 500 (Internal Server Error)
How can I do?
Edit:
www.page.com is a subdomain. Is necessary to do some configuration when a subdomain is used to Ajax request?
And the folders organization is:
/CI-example
---/application/controllers/control.php
---/system
---/site/js/ajaxRequest.js
As I am getting here, while you are sending ajax requests to the server than it's returning 500 (Internal Server Error). I'm sure that the error is from server side, and there may be following reason-
If everything is fine in the codes, then may be your base_url is different from what you are requesting. Yes this can cause the problem, for example if you have hosted your web application and your base_url is www.mysite.com and you are requesting for mysite.com.
Next reason may be, that you have developed your project in windows or any system which is in-case-sensitive but when you will upload to any linux like server than each and every file name will be case-sensitive. For example suppose a model file name you have given is MyModel.php but when you will load the model, it will generate the error like Unable to find the specific class.
You cannot make HTTP POST requests using AJAX to a different domain, unless that page allows you to do so using a special header called "Access-Control-Allow-Origin".
localhost is different to page.com which is why this will not work.
Response on the http://www.page.com's url say something has gone wrong during the page execution. Your PHP error log should help you to find what.
Adding the line ini_set('display_errors', 1) might return the error to the ajax request, in the error handler. Don't forget to remove the line after use, you don't want this lying around in production code.
The second error is : 500 (Internal Server Error)
This means there was an error on the server side - not a cross-origin policy problem.
This is probably an error in the execution of your PHP script.
Check your error log (e.g : if you use the standard LAMP stack, the error log should be somewhere in /var/log/apache2/)
try this,
http://localhost/CI-example/index.php/control/controlHome
instead of
http://localhost/CI-example/site/index.php/control/controlHome
in your ajax URL.
As from your folder structure, there is no need to include "site" in your URL

Categories

Resources