Access-Control-Allow-Origin header not present using renderData()

64 views
Skip to first unread message

jusufd

unread,
Nov 1, 2017, 10:50:55 AM11/1/17
to framework-one
Hi All,

I am having an error that Access-Control-Allow-Origin header is not present.

I am currently using the FW/1 version 4.1 and run on Lucee 5.0. 
From the controller I am using this statement: 
framework.renderData().data(rc.jsonResult).type("json"). 
I set the preflightOptions either true or false and set the optionsAccessControl.origin = "*" and giving me the error. 

However if I am using the view like below and everything is fine. 
<cfheader name="Access-Control-Allow-Origin" value="*">
<cfheader name="Access-Control-Allow-Methods" value="DELETE,GET,HEAD,PATCH,POST,PUT">
<cfheader name="Access-Control-Max-Age" value="3600">
<cfheader name="Access-Control-Allow-Headers" value="Authorization, Content-Type" />
<cfcontent type="application/json; charset=utf-8">
<cfoutput>#serializejson(rc.jsonResult)#</cfoutput>

I prefer to use the built-in renderData() instead using my own view but for some reason I got this Access-Control-Allow-Origin not present.

I am not sure what I need to correct this.  Please help!

Thanks in advance.

Best.
JY.


Sean Corfield

unread,
Nov 1, 2017, 11:06:12 AM11/1/17
to framew...@googlegroups.com

In order for Access-Control stuff to kick in, you must be using routes – and an incoming route must have matched (along with the method being OPTION) – as well as setting preflightOptions = true.

 

What are your routes? What was the incoming request?

 

Sean Corfield -- (970) FOR-SEAN -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

 


From: framew...@googlegroups.com <framew...@googlegroups.com> on behalf of jusufd <jus...@gmail.com>
Sent: Wednesday, November 1, 2017 7:50:55 AM
To: framework-one
Subject: [framework-one] Access-Control-Allow-Origin header not present using renderData()
 
--
FW/1 documentation: http://framework-one.github.io
FW/1 source code: http://github.com/framework-one/fw1
FW/1 chat / support: https://gitter.im/framework-one/fw1
FW/1 mailing list: http://groups.google.com/group/framework-one
---
You received this message because you are subscribed to the Google Groups "framework-one" group.
To unsubscribe from this group and stop receiving emails from it, send an email to framework-on...@googlegroups.com.
Visit this group at https://groups.google.com/group/framework-one.
For more options, visit https://groups.google.com/d/optout.

jusufd

unread,
Nov 1, 2017, 11:13:00 AM11/1/17
to framework-one
Sean,

Here is my route:
routes = [
                    { "$GET/api/user/$" = "/user/show" },
                    { "$PUT/api/user/$" = "/user/update/" },
                    { "$GET/api/user/:id/$" = "/user/show/id/:id" },
                    { "$POST/api/user/$" = "/user/new" },
                    { "$POST/api/user/:id/$" = "/user/update/id/:id" },
                    { "$DELETE/api/user/:id/$" = "/user/delete/id/:id" },
                    { "$GET/api/user/findByEmail/$" = "/user/findBy/" },
                    { "$POST/api/contact/$" = "/contact/new" }
                ]

I added the { "$OPTIONS/api/contact/$" = "/contact/new" } and still no luck.

Thanks.
Reply all
Reply to author
Forward
0 new messages