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
Newbie in Web Programming...
by
incendio
[
Today
at 04:02:38 am]
Named range
by
backprop
[
Today
at 03:09:07 am]
FPC Deluxe doesn't work
by
TRon
[
Today
at 02:06:21 am]
Boolean type
by
440bx
[
Today
at 01:45:29 am]
[SOLVED] WebP images and ...
by
TRon
[
Today
at 01:23:47 am]
Knob Finger Spinner Graph...
by
SandyG
[
Today
at 12:40:58 am]
Using a custom record as ...
by
ilowry
[April 21, 2025, 09:13:00 pm]
Testing with SQLite3DataS...
by
dseligo
[April 21, 2025, 08:59:22 pm]
Best way to exchange data...
by
Hansvb
[April 21, 2025, 08:36:43 pm]
BGRA Shader Sphere Map
by
d2010
[April 21, 2025, 06:27:14 pm]
MVP made easier.
by
cdbc
[April 21, 2025, 05:38:10 pm]
Reading data files that a...
by
OC DelGuy
[April 21, 2025, 05:12:29 pm]
ToDoList package, support...
by
cdbc
[April 21, 2025, 04:46:00 pm]
Create DB
by
Handoko
[April 21, 2025, 04:23:15 pm]
macOS 15.4 Breaks All Com...
by
moinsen
[April 21, 2025, 04:16:24 pm]
Cannot execute Lazarus ID...
by
robert rozee
[April 21, 2025, 03:26:10 pm]
Recamán's Sequence Curve ...
by
TRon
[April 21, 2025, 03:05:03 pm]
HTMLViewer JavaScript dem...
by
myisjwj
[April 21, 2025, 02:22:46 pm]
How to DIY a filerec reco...
by
TYDQ
[April 21, 2025, 10:58:11 am]
Error: Illegal parameter:...
by
daniel_sap
[April 21, 2025, 06:45:47 am]
Times Tables Curves: Some...
by
Boleeman
[April 21, 2025, 04:45:52 am]
accessing array members i...
by
TRon
[April 21, 2025, 01:01:35 am]
RGB Plasma
by
Gigatron
[April 20, 2025, 11:26:28 pm]
Lectura puerto serie
by
Edson
[April 20, 2025, 07:42:47 pm]
Compile Error on Assign f...
by
marcov
[April 20, 2025, 03:10:08 pm]
« previous
next »
Print
Pages:
1
[
2
]
Author
Topic: (solved)how to define cors in free pascal (Read 3042 times)
Packs
Sr. Member
Posts: 485
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: 485
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: 16783
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: 485
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: 16783
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: 485
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: 485
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: 485
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