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
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Possible bug in Lazarus 4...
by
Zvoni
[
Today
at 01:20:07 pm]
fpcupdeluxe gets error wh...
by
ccrause
[
Today
at 01:08:01 pm]
Problem with TSQLQuery
by
sch61
[
Today
at 12:40:25 pm]
[SOLVED] progress dialog ...
by
Thaddy
[
Today
at 11:34:32 am]
Convert string with Key-V...
by
Warfley
[
Today
at 10:41:49 am]
Ho Ho Ho IntraWeb in Laza...
by
Thaddy
[
Today
at 09:58:28 am]
Lazarus is not working
by
cdbc
[
Today
at 09:51:39 am]
Clipboard Formats
by
AlexTP
[
Today
at 08:51:22 am]
TurboBird for FireBird 5
by
maurog
[
Today
at 04:45:18 am]
TurboBird IBX
by
maurog
[
Today
at 04:41:20 am]
a bug about FPC spurce
by
dsiders
[
Today
at 02:44:18 am]
How to get at files that ...
by
Martin_fr
[
Today
at 12:33:32 am]
Need help converting a C+...
by
jamie
[
Today
at 12:30:59 am]
Lazarus Bugfix Release 4...
by
calebs
[December 07, 2025, 10:37:53 pm]
make cycle fails on macOS...
by
Thausand
[December 07, 2025, 10:05:00 pm]
Matching video to form
by
Thausand
[December 07, 2025, 09:48:04 pm]
[Solved] Need help with c...
by
Thausand
[December 07, 2025, 08:03:53 pm]
TTagEdit Component 1.2
by
JD
[December 07, 2025, 08:02:41 pm]
[SOLVED] Form OnTop not w...
by
Pe3s
[December 07, 2025, 07:32:12 pm]
Save record to BLOB Field
by
Sc0li0sis
[December 07, 2025, 07:31:24 pm]
$ifdef highlighting
by
440bx
[December 07, 2025, 07:09:02 pm]
[BUG REPORT] Code explore...
by
Martin_fr
[December 07, 2025, 02:54:20 pm]
Qt6 / X11: problem with G...
by
paweld
[December 07, 2025, 02:44:07 pm]
Dumb Problems Contest!
by
Thaddy
[December 07, 2025, 02:41:59 pm]
Please ask about the valu...
by
zzzzzzz7
[December 07, 2025, 02:14:52 pm]
« previous
next »
Print
Pages:
1
[
2
]
Author
Topic: (solved)how to define cors in free pascal (Read 4112 times)
Packs
Sr. Member
Posts: 492
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: 2031
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: 492
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: 18507
Here stood a man who saw the Elbe and jumped it.
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
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.
Packs
Sr. Member
Posts: 492
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: 18507
Here stood a man who saw the Elbe and jumped it.
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
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.
Packs
Sr. Member
Posts: 492
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: 492
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: 492
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