Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
(solved)how to define cors in free pascal
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
ShowModal has a bug in Li...
by
TRon
[
Today
at 03:02:45 am]
Why isn't Lazarus / Free ...
by
Seenkao
[
Today
at 02:24:02 am]
Ctrl-V doesn't work anymo...
by
TRon
[
Today
at 01:55:01 am]
Why there is no build-in ...
by
TRon
[April 27, 2025, 11:36:56 pm]
Text Property is conflict...
by
jamie
[April 27, 2025, 09:21:33 pm]
EOF Problem
by
J-G
[April 27, 2025, 09:20:05 pm]
upvote a reply
by
440bx
[April 27, 2025, 07:56:59 pm]
Testing with SQLite3DataS...
by
paweld
[April 27, 2025, 07:12:58 pm]
Fixing or working around ...
by
Nel_Fie
[April 27, 2025, 06:10:49 pm]
Fpcupdeluxe
by
DonAlfredo
[April 27, 2025, 04:34:58 pm]
[solved] macro for code ?
by
Tomas Hajny
[April 27, 2025, 04:24:09 pm]
TAudio- play, edit, conve...
by
minesadorada
[April 27, 2025, 03:33:45 pm]
Fpcupdeluxe and trunk
by
LemonParty
[April 27, 2025, 02:17:28 pm]
[SOLVED] Problems accessi...
by
Ever
[April 27, 2025, 01:41:45 pm]
String Grid move to cell
by
bowlofpetunias
[April 27, 2025, 01:05:41 pm]
Macos Sequoia Lazarus 3.8...
by
Nimbus
[April 27, 2025, 12:41:34 pm]
Does TIpHtmlPanel support...
by
daniel_sap
[April 27, 2025, 12:13:30 pm]
Win11 themes not followed
by
han
[April 27, 2025, 11:11:07 am]
Does anyone have the idea...
by
TYDQ
[April 27, 2025, 09:45:38 am]
Breakout clone with rayli...
by
Guva
[April 27, 2025, 06:19:10 am]
Newbie in Web Programming...
by
incendio
[April 27, 2025, 03:07:51 am]
Convert this Python code ...
by
Jurassic Pork
[April 27, 2025, 02:56:08 am]
I get access violation wh...
by
Martin_fr
[April 27, 2025, 01:23:11 am]
A Digital Fidget Spinner-...
by
Boleeman
[April 27, 2025, 01:01:20 am]
full featured Android Nat...
by
Seenkao
[April 26, 2025, 10:51:30 pm]
« previous
next »
Print
Pages:
1
[
2
]
Author
Topic: (solved)how to define cors in free pascal (Read 3061 times)
Packs
Sr. Member
Posts: 486
Re: how to define cors in free pascal
«
Reply #15 on:
September 24, 2024, 05:53:27 pm »
No . it is not working
Logged
Warfley
Hero Member
Posts: 1872
Re: how to define cors in free pascal
«
Reply #16 on:
September 25, 2024, 01:36:13 am »
What does your browsers network monitor say when you do the request? You can open the developer tools, enable the network monitor and it will show you all requests and responses sent by the website, including headers
Logged
GitHub:
https://github.com/Warfley
Packs
Sr. Member
Posts: 486
Re: how to define cors in free pascal
«
Reply #17 on:
September 25, 2024, 08:02:09 pm »
Have you tried with datamodule and mydac component.
I think mydac is blocking .
Logged
Thaddy
Hero Member
Posts: 16813
Ceterum censeo Trump esse delendam
Re: how to define cors in free pascal
«
Reply #18 on:
September 26, 2024, 01:51:17 pm »
Yes, so?
You already used a thread.
Logged
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.
Packs
Sr. Member
Posts: 486
Re: how to define cors in free pascal
«
Reply #19 on:
September 26, 2024, 01:58:28 pm »
I have checked all options it is not working with angular .
in angular browser it self is calling pre-flight and sending error to angular code .
it is not reaching server . so server can't able to send the response header for options .
Logged
Thaddy
Hero Member
Posts: 16813
Ceterum censeo Trump esse delendam
Re: how to define cors in free pascal
«
Reply #20 on:
September 26, 2024, 03:58:11 pm »
Show us a short compilable, but not working example.
Logged
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.
Packs
Sr. Member
Posts: 486
Re: how to define cors in free pascal
«
Reply #21 on:
September 28, 2024, 08:48:52 am »
Browser not calling lazarus rest api it is giving cors error in prefight request . I have other api on same server different port which is golang it is working perfectly . I am sharing golang and lazarus header
golnag Header
Code: Pascal
[Select]
[+]
[-]
authority
:
xxx
:
7009
method
:
POST
path
:
/
v1
/
api
/
get_apidata
scheme
:
https
accept
:
application
/
json
accept
-
encoding
:
gzip
,
deflate
,
br
,
zstd
accept
-
language
:
en
-
US
,
en
;
q
=
0.9
,
en
-
IN
;
q
=
0.8
authorization
:
Bearer XXXX
content
-
length
:
120
content
-
type
:
application
/
json
origin
:
http
:
//localhost:4200
priority
:
u
=
1
,
i
referer
:
http
:
//localhost:4200/
sec
-
ch
-
ua
:
"Microsoft Edge"
;
v
=
"
129
"
,
"
Not
=
A?Brand"
;
v
=
"
8
"
,
"Chromium"
;
v
=
"
129
"
sec
-
ch
-
ua
-
mobile
:
?
0
sec
-
ch
-
ua
-
platform
:
"Windows"
sec
-
fetch
-
dest
:
empty
sec
-
fetch
-
mode
:
cors
sec
-
fetch
-
site
:
cross
-
site
user
-
agent
:
Mozilla
/
5.0
(
Windows NT
10.0
;
Win64
;
x64
)
AppleWebKit
/
537.36
(
KHTML
,
like Gecko
)
Chrome
/
129
.
0
.
0
.
0 Safari
/
537.36
Edg
/
129
.
0
.
0
.
0
Lazrus Header
Code: Pascal
[Select]
[+]
[-]
accept
:
application
/
json
authorization
:
Bearer XXXX
content
-
type
:
application
/
json
referer
:
http
:
//localhost:4200/
sec
-
ch
-
ua
:
"Microsoft Edge"
;
v
=
"
129
"
,
"
Not
=
A?Brand"
;
v
=
"
8
"
,
"Chromium"
;
v
=
"
129
"
sec
-
ch
-
ua
-
mobile
:
?
0
sec
-
ch
-
ua
-
platform
:
"Windows"
user
-
agent
:
Mozilla
/
5.0
(
Windows NT
10.0
;
Win64
;
x64
)
AppleWebKit
/
537.36
(
KHTML
,
like Gecko
)
Chrome
/
129
.
0
.
0
.
0 Safari
/
537.36
Edg
/
129
.
0
.
0
.
0
Logged
Packs
Sr. Member
Posts: 486
Re: how to define cors in free pascal
«
Reply #22 on:
September 28, 2024, 09:32:44 am »
Thank you every one .
It is working now .
solution : THTTPApplication.BeforeRequest manged for options request
Logged
joguenco
Newbie
Posts: 2
Re: (solved)how to define cors in free pascal
«
Reply #23 on:
March 27, 2025, 10:57:58 pm »
Hi, please be nice. Could you share the solution with source code? I have the same problem with POST method
Logged
Packs
Sr. Member
Posts: 486
Re: (solved)how to define cors in free pascal
«
Reply #24 on:
March 30, 2025, 07:25:15 pm »
Code: Pascal
[Select]
[+]
[-]
with
HTTPRouter
do
begin
RegisterRoute
(
'/currenttime'
,
rmPost
,
@
timeEndpoint
)
;
BeforeRequest
:
=
@
Before_request_router
;
AfterRequest
:
=
@
After_request_router
;
end
;
procedure
THttpServerThread
.
Before_request_router
(
Sender
:
TObject
;
req
:
TRequest
;
res
:
TResponse
)
;
begin
Frmmain
.
Memo1
.
Lines
.
Add
(
'before request '
)
;
with
res
do
begin
SetCustomHeader
(
'Access-Control-Allow-Credentials'
,
'true'
)
;
SetCustomHeader
(
'Access-Control-Allow-Origin'
,
'*'
)
;
SetCustomHeader
(
'Access-Control-Max-Age'
,
'86400'
)
;
SetCustomHeader
(
'Access-Control-Allow-Methods'
,
'POST, GET, OPTIONS, PUT, DELETE'
)
;
SetCustomHeader
(
'Access-Control-Allow-Headers'
,
'Originname,Pathname,Anonymous,Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization,responsetype'
)
;
end
;
if
req
.
Method
.
ToUpper
=
'OPTIONS'
then
begin
Frmmain
.
Memo1
.
Lines
.
Add
(
'before options '
)
;
res
.
Code
:
=
204
;
res
.
SendResponse
;
//exit;
end
;
end
;
procedure
THttpServerThread
.
After_request_router
(
Sender
:
TObject
;
ARequest
:
TRequest
;
AResponse
:
TResponse
)
;
begin
Frmmain
.
Memo1
.
Lines
.
Add
(
'After http request '
)
;
end
;
this will work for you.
Logged
joguenco
Newbie
Posts: 2
Re: (solved)how to define cors in free pascal
«
Reply #25 on:
March 31, 2025, 05:38:12 pm »
Thank you very much
Logged
Print
Pages:
1
[
2
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
(solved)how to define cors in free pascal
TinyPortal
© 2005-2018