I'm trying to get my server to redirect to another page in my 'public folder'. When I use:
response.redirect(path.join(__dirname, '../public/user_home.html'))
I get and error net::ERR_UNSAFE_REDIRECT
On the client side I have:
$.get( "/user_home", function( data ) {console.log(data)};
I can't find anything about this error. Am I going about this incorrectly?
Your public folder is already available if you have static middleware configured in your app.
app.use(express.static('public'))
You can use:
res.redirect("/user_home.html");
response.redirect(path.join(__dirname, '../public/user_home.html'),safe=true)
Related
below is put request in a function:
form.put(`/pos/${form.meal_type_id}/${form.user_id}/${form.group_id}/${form.date_served}/${form.adult}/${value}/false`)
Here is the route
Route::put('/pos/{meal_type_id}/{user_id}/{group_id}/{date_served}/{adult}/{meal_id}/{void}', [PosController::class, 'voidMeal'])
->middleware(['auth', 'verified'])->name('pos.voidTally');
And the function in the controller:
public function voidMeal($meal_type_id, $user, $group_id, $date_served, $adult, $meal_id, $void)
I no longer need to pass ${form.user_id}. But when I remove it from the request/route/controller I get a 404 error. Can anyone explain?
Here is the version without the user in case I'm making a mistake and not seeing it.
form.put(`/pos/${form.meal_type_id}/${form.group_id}/${form.date_served}/${form.adult}/${value}/false`)
Route::put('/pos/{meal_type_id}/{group_id}/{date_served}/{adult}/{meal_id}/{void}', [PosController::class, 'voidMeal'])
->middleware(['auth', 'verified'])->name('pos.voidTally');
public function voidMeal($meal_type_id, $group_id, $date_served, $adult, $meal_id, $void)
Please let me know if more info is needed. I don't think more info is needed, so if there is something else, that's probably it.
I'm trying to learn JavaScript for Odoo. I've created a new class in my custom module's js file.
openerp.odoojs = function(instance){
console.log('instance: ',instance);
console.log('session: ',instance.session);
}
This is what I'm getting when I browse the session object in the console.
But when I try to access the uid or any other attribute or parameter like instance.session.uid, I'm getting it as undefined. Please help! I'm stuck with this. I'm unable proceed further.
Try to extend the 'Backbone.Model' like 'PosModel' in 'model.js' file. Try to define the 'initialize' function, where you will find two parameters in function arguments as 'session' and 'attributes'. Here you can find the uid using 'session.uid'.
I have just installed the yii-user-management module but when I try to access it via browser I get
Fatal error: Call to a member function get() on a non-object in ..../modules/user/models/YumUser.php on line 368
$relations = Yii::app()->cache->get('yum_user_relations');
Appreciate any help.
It seems like the yii-user-management module requires a cache component for it to work. So in your application config add the cache component as
'cache'=>array(
'class'=>'CDummyCache',
),
Here we are using CDummyCache copmponent which is, as its name says, acts as a dummy. You can replace it by any other cache components as described here
Thanks #dInGd0nG. Your answer works for me too. Just would want to remind people to follow his link. In the link, you will see the configure statement shall be added in
'components'=>array(
......
'cache'=>array(
'class'=>'CDummyCache',
),
)
After logged in successfully, Yii does not executing any page.
Showing an error:
Error 404 Unable to resolve the request "membersdet/index"
Here membersdet is controller Id and index is an action.
Make sure the filename of your controller is EXACTLY "MembersdetController.php". It is case sensitive.
I guess you were developing on local machine under Windows OS and server runs on *nix system. That's normal issue for novice developers, that they forget about case sensitive file system in *nix.
It is because of wrong controller file name given or may be actionIndex() method is not in your controller.
I have had a similar problem and got it solved. In this case the file was correctly named but the class name was wrongly spelled. When these two do not correspond, you could get this error too.
Check case sensitive exactly your controller: MembersdetController
Check alias (common in config/main.php) map with namespace in your controller
Yii::setAlias('#tienn2t', dirname(dirname(__DIR__)) . '/tienn2t');
In MembersdetController.php file
<?php
namespace tienn2t\controllers;
use Yii;
use yii\web\Controller;
class MembersdetController extends Controller{
public function actionIndex(){
echo 1;die;
}
}
There is not enough information in the question, but maybe you have an incorrect .htaccess or if you don't have an htaccess at all you should use the url:
http://host/index.php?r=membersdet/index
Make sure you have MembersdetController in /protected/controllers/ and this class "is a" CController and has a public method named actionIndex().
Check errorHandler block in your config file.
I had fix this error like this
'errorHandler' => [
'errorAction' => 'error/index',
],
By the way you should have appropriate ErrorController in your module and /error/index.php
file in view folder.
Hope will help you.
I am needing to get the application root within a Restlet resource class (it extends ServerResource). My end goal is trying to return a full explicit path to another Resource.
I am currently using getRequest().getResourceRef().getPath() and this almost gets me what I need. This does not return the full URL (like http://example.com/app), it returns to me /resourceName. So two problems I'm having with that, one is it is missing the schema (the http or https part) and server name, the other is it does not return where the application has been mounted to.
So given a person resource at 'http://dev.example.com/app_name/person', I would like to find a way to get back 'http://dev.example.com/app_name'.
I am using Restlet 2.0 RC3 and deploying it to GAE.
It looks like getRequest().getRootRef().toString() gives me what I want. I tried using a combination of method calls of getRequest().getRootRef() (like getPath or getRelativePart) but either they gave me something I didn't want or null.
Just get the base url from service context, then share it with the resources and add resource path if needed.
MyServlet.init():
String contextPath = getServletContext().getContextPath();
getApplication().getContext().getAttributes().put("contextPath", contextPath);
MyResource:
String contextPath = getContext().getAttributes().get("contextPath");
request.getRootRef() or request.getHostRef()?
The servlet's context is accessible from the restlet's application:
org.restlet.Application app = org.restlet.Application.getCurrent();
javax.servlet.ServletContext ctx = ((javax.servlet.ServletContext) app.getContext().getAttributes().get("org.restlet.ext.servlet.ServletContext"));
String path = ctx.getResource("").toString();