angularjs html5 hash url - angularjs

I am using server side google oauth in angular.js,
Suppose my redirect url is localhost:8000/redirect. To remove # in angularjs I am using
$locationProvider.html5Mode(true);
But, when i visit the url I get an error :
Error response
Error code 404.
Message: File not found.
Error code explanation: 404 = Nothing matches the given URI.
However if I type the url manually i.e localhost:8000/#redirect then I get what I expected and then redirects to localhost:8000/redirect
I have also tried to add # from Google app console. But, that is not allowed.
So how to remove hash completely ?

Related

Nextjs dynamic route page return 403 Forbidden error for only one specific user dynamic route

I have my route defined as patients/[userID].tsx in pages dir.
When I tried to access one of the specific active userID (eg. patients/7917067d) it gave 403 Forbidden error in prod only, In dev, it is working fine.
FYI, when I enter the wrong userId it gives 404 which is correct behaviour but don't know why only this userId which is correct gives a 403 error.
NOTE: I am using Static Generation with Client-side data fetching
Upgrading the nextjs package to 12.3.3 did the work.
Refer this github issue for more details.

React app SPA on S3 AWS while refreshing the page shows 404 page

I have a SPA made with React JS on a S3 Bucket and I’m using Cloud Front to work through HTTPS and with a custom domain. When I refresh the page - if I have another Route that is not the BASE_URL (for example domain.com/something), S3 sends me a 404 error.
I also tried redirecting the error page to BASE_URL but it doesn’t work, it redirects me to the Http default domain that S3 provides me and again, it gives me an 404 error page.
I don’t know if there exists an alternative way to keep the URL without any change (domain.com/page) and avoid the 404 error the way a web server (apache) handles.
If you are using CloudFront to host s3 website, the effective way to get rid of 404 on reload of non-index route like www.google.com/about or similar non / is by the following steps:
Go to your CloudFront distribution
Go to Error Pages
Create a new error page with the following params:
HTTP Error Code: 404
TTL: 0
Custom Error Response: Yes
Response Page Path: /index.html
HTTP Response Code: 200
enjoy
credits going to this article https://gist.github.com/bradwestfall/b5b0e450015dbc9b4e56e5f398df48ff
You have two options. Either use CloudFront error page as a catch-all that redirects to / (you mentioned you tried setting an error page but did not detail what you did. This should work). The downside is that it will respond with the HTML page for all not found paths, even for mistyped CSS paths, for example.
The other solution is to use Lambda#Edge to rewrite the origin request path. This is a more customizable solution and you can define which paths you want to redirect to the root.

Autodesk Forge API tutorial Get a 3-Legged Token 404 error

I have a similar issue to this post.
I am following the 3-legged tutorial on the Forge API website here, and I matched the callback URI and URL, tried swapping the data:read for viewables:read, and tried switching to https:// and not http:// but I'm still getting an error when I run the app and login via the link in the tutorial which I adjusted with my information.
The error I get is:
Not Found.
The requested URL /parking/oauth/callback was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Do you know what could be wrong?

firebase 404 page configuration in angularjs

I try to add a 404 page into my angularjs project which is hosted on firebase servers. I created a custom 404 page and added following code:
function routeConfig($stateProvider, $urlRouterProvider, $locationProvider)
{
$urlRouterProvider.otherwise('/pages/errors/error-404');
}
Now it works but I am missing something because when I check in the browser's network panel the status code is "200" but it should be "404".
What should I do for that?
$urlRouterProvider.otherwise just guides AngularJS that which URL it should navigate to when no URL matches the provider's rules.
This doesn't signify that a resource is not found on the server (which essentially returns 404). To do that, you need to do a lot more including serving this 404 page from the server with 404 as the status code.
Here is a resource to point you in the right direction:
AngularJS UI router handling 404s

Angular js Passport example is not working

I am trying to follow this example:
source : https://github.com/DaftMonk/angular-passport
demo website: http://angular-passport.herokuapp.com/
I copied and pasted to my app and server almost same.
Routes work (in server side and client side too)
When I tried to log in or sign up I get a 404 error from server.
here is my server-side routes part.
I checked app.get('/robots.txt') works.
and this is routes part for login (that gave me 404 error):
app.post('/auth/session', session.login);
but I tried:
app.post('/auth/session', function(req,res){
console.log('here is session requested');
res.sendfile('robots.txt');
});
This code for checking whether server does respond well.
But still I got 404 error.
How can I fix this works? Ir how can I test this post routings with console.log or, something else?
Try using postman chrome extension for debugging RESTful api s
https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en
I think your issue may just be a simple path adjustment - sendFile requires a full path to be defined (you have provided a relative path by just using the filename) - try this:
res.sendFile('robots.txt', { root: __dirname + '/' });
Note that res.sendfile (lowercase 'f') has been deprecated and replaced with res.sendFile in Express 4.

Resources