Hi!
On Wed, Apr 29, 2015 at 01:01:57PM +0100, Rob Willett wrote:
> We also tried the SecureCors version.
This should work:
---cut---
#!/usr/bin/perl -w
use Mojolicious::Lite;
plugin 'SecureCORS', { max_age => 1728000 };
app->routes->cors('/data');
under '/data' => {
'cors.origin' => '*',
'cors.headers' => 'Content-Type',
};
get '/' => sub {
my $self = shift;
print "GET found\n";
$self->render(text => 'ok');
};
post '/' => sub {
my $self = shift;
print "\nPOST found\n";
$self->render(text => 'POST ok');
};
app->secrets(['My very secret passphrase.']);
app->start;
---cut---
Test it with:
curl -v -X OPTIONS -H 'Origin: site.tld' -H 'Access-Control-Request-Method:
POST' http://localhost:3000/data
curl -v -H 'Origin: site.tld' --data "id=123" http://localhost:3000/data
curl -v -H 'Origin: site.tld' http://localhost:3000/data
--
WBR, Alex.
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.