Hello all,
I have been using Pyramid for my REST application and have been using JWT.
in my __init__.py file I have these lines:
def add_cors_headers_response_callback(event):
    def cors_headers(request, response):
        response.headers.update({
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Methods': 'POST,GET,DELETE,PUT,OPTIONS',
'Access-Control-Allow-Headers': 'Origin, Content-Type, Accept, Authorization',
        'Access-Control-Allow-Credentials': 'true',
        'Access-Control-Max-Age': '1728000',
        })
    event.request.add_response_callback(cors_headers)

def main(global_config, **settings):
    config = Configurator(settings=settings)
config.add_route("orgid","/organisation/{orgname}/{orgtype}/{yearstart}/{yearend}")
    config.add_route("organisation","/organisation/{orgcode}")
    config.add_route("organisations","/organisations")
    config.add_route("orgyears","/orgyears/{orgname}/{orgtype}")
    config.add_route("users",'/users')
    config.add_route('user','/user')
    config.add_route("accounts",'/accounts')
    config.add_route("account",'/account/{accountcode}')
    config.add_route("login",'/login')
    config.add_route("groupsubgroup","/groupsubgroup/{groupcode}")
    config.add_route("groupsubgroups","/groupsubgroups")
    config.add_route("groupDetails","/groupDetails/{groupcode}")
    config.scan("gkcore.views")
    config.add_subscriber(add_cors_headers_response_callback, NewRequest)
    return config.make_wsgi_app()

So I guess I have set the configuration with right headers for CORS.
Now when I make a call for getting token from a certain function called Login I do get the token correctly and I have tested for it. When I access a route such as groupsubgroups in the above example I do send the token back with the request.
I use AngularJS but I get the said problem in the subject line.
But what makes me more confused is that when I use the REST client plugin in Firefox, I get the correct response back with no such problem. I also confirmed that the get request format in $http of Angular is also correct and matches the route. But I get the 404 not found error and at the server side I see the said problem.
Can some one clear my confusion?
Do you need more code to see and if yes then what exactly?
Happy hacking.
Krishnakant.

--
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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 https://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to