Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 17 13:24
    varioous commented #65
  • Aug 04 10:10
    cundd commented #65
  • Jul 31 10:09
    cundd commented #65
  • Jul 31 10:01
    r3h6 opened #65
  • Jun 16 12:42

    cundd on v4

    Add support for `REDIRECT_TYPO3… (compare)

  • Jun 15 08:59

    cundd on v4

    Raise version number to 4.1.0-d… Replace tabs with spaces Add support to specify a Expire… and 2 more (compare)

  • Jun 09 13:12

    cundd on expires-header-config

    Fix a bug where wrong config-ke… (compare)

  • Jun 01 10:08
    cundd closed #64
  • Jun 01 10:01
    issibi commented #64
  • Jun 01 09:49
    cundd commented #64
  • May 30 21:47
    issibi opened #64
  • Apr 20 10:13
    Travis cundd/rest (3.6.1) passed (612)
  • Apr 20 10:13
    Travis cundd/rest (3.6.1) passed (612)
  • Apr 20 10:12
    Travis cundd/rest (3.6.1) passed (612)
  • Apr 20 10:09
    Travis cundd/rest (3.6.1) passed (612)
  • Apr 20 10:09
    Travis cundd/rest (3.6.1) passed (612)
  • Apr 20 10:09
    Travis cundd/rest (3.6.1) passed (612)
  • Apr 20 10:08
    Travis cundd/rest (3.6.1) passed (612)
  • Apr 20 10:07
    Travis cundd/rest (3.6.1) passed (612)
  • Apr 20 10:07
    Travis cundd/rest (3.6.1) passed (612)
Daniel Corn
@cundd
Maybe it needs to be
$restRequestBasePath = (string)(getenv('TYPO3_REST_REQUEST_BASE_PATH') ?: (getenv('REDIRECT_TYPO3_REST_REQUEST_BASE_PATH')));
jan-runkel-zeitgleich
@jan-runkel-zeitgleich
we need this in ext_localconf.php and ReqeustFactory.php (L:185)
:)
Daniel Corn
@cundd
$restRequestBasePath = (string)(getenv('TYPO3_REST_REQUEST_BASE_PATH') ?: getenv('REDIRECT_TYPO3_REST_REQUEST_BASE_PATH'));
This one should work
jan-runkel-zeitgleich
@jan-runkel-zeitgleich
yes
Daniel Corn
@cundd
I'll have a look at it in the afternoon.
jan-runkel-zeitgleich
@jan-runkel-zeitgleich
thanks
Daniel Corn
@cundd
You're on version 4, correct?
jan-runkel-zeitgleich
@jan-runkel-zeitgleich
yes
4.0.0
Daniel Corn
@cundd
:+1:
Daniel Corn
@cundd
I pushed the change to github
jan-runkel-zeitgleich
@jan-runkel-zeitgleich
thanks
miguel
@miguel1995

Hi Daniel, I have an error with CORS when I call form different origins, except in my local postman. When I send a GET it's ok, but not in POST.
"Access to fetch at 'http://mydomain.com/rest/eventos/mymodel' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status."

-->This is configuration in TYPOSCRIPT:

plugin.tx_rest.settings {
 responseHeaders {                
    Access-Control-Allow-Origin = *
Access-Control-Allow-Methods = POST, GET, OPTIONS
      Access-Control-Allow-Headers = Content-Type 
 }  
}
plugin.tx_rest.settings.paths {
 1 {
    path = unal-unal_circular-circurlarEvent
    read = allow
    write = allow
    handlerClass = \UNAL\UnalCircular\Rest\EventHandler
 }
}

--> This is my configuration in .htacces :
...
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header set Access-Control-Allow-Headers "append,delete,entries,foreach,get,has,keys,set,values,Authorization"
...

Daniel Corn
@cundd
Hi @miguel1995! I think the problem is that the preflight (=OPTIONS) request doesn’t receive an Ok response. Is there a route for OPTIONS in your handler?
And it’s possible that you need a OPTIONS route for every URI path you send a POST to
miguel
@miguel1995
Hi @cundd I don't have a route for OPTIONS in my handler. Can you give me an example of some implementation?, please .
Daniel Corn
@cundd
Hi @miguel1995 that’s quite simple. Have a look at https://github.com/cundd/rest/blob/v4/Classes/Handler/CrudHandler.php#L203
miguel
@miguel1995

Hello Daniel.
I want to thank you for your quick responses.

I could already create the OPTIONS path with the example you gave me. I can consume my POST service without problems. I tried Jquery and javascript fetch and everything works fine. :)
But this only works if I make the POST without headers.

When I add any header, for example : headers:{ 'Content-Type': 'application/json' } it doesn't work and it returns an error:

"... has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response."

Do you have any idea?
Daniel Corn
@cundd
When you make a CORS request (from http://webapp-domain:port to http://api-domain:port) you also have to explicitly allow which headers can be sent.
I usually add something like the following TypoScript:
plugin.tx_rest.settings {
    # Overwrite the response's headers with the following ones
    responseHeaders {
        # Allow the client to send a `Content-Type` header for requests
        Access-Control-Allow-Headers = Content-Type
    }
}
If you need more fine-grained control, it should also be possible to return a Response from you Options-route (instead of only saying return true;)
Tamasu
@xTamasu
Hi, I cant get the extension to work. How can I call a table with all feusers in it? I want to get/post/update/delete feusers with this rest api. It should be called via mydomain.com/rest/feusers. Where should I start? I already installed it and was greeted with {"message":"Good Morning!"} at /rest/
Daniel Corn
@cundd
@xTamasu the next step will be to create a resource-definition like in https://rest.corn.rest/Configuration/Basic/#namespaces-and-vendor-prefix
The model you are looking for will most likely be \TYPO3\CMS\Extbase\Domain\Model\FrontendUser
Tamasu
@xTamasu

So I created an own extension and added setup.ts with
company_ext_programrestapi-users { path = typo3/sysext/extbase/Classes/Domain/Model/FrontendUser.php read = allow write = allow }

But now it throws errors, I think I configured the wrong path. Is there a way I can access internal models? (relative new to typo3)

Daniel Corn
@cundd
oh. sorry I forgot, that it currently does not work out of the box with internal objects (because the resource-path can not be created for the deeply nested namespaces like \TYPO3\CMS\Extbase
but you can check out https://rest.corn.rest/Customize/ and fetch the FeUsers in your handler
Daniel Corn
@cundd
The problem with TYPO3's own classes is, that the vendor basically has two parts TYPO3 and CMS followed by the extension name. The REST extension must be able to take the request path and split it up into vendor and model, but it also needs to support deeper nested models (e.g. Vendor\NiceExtension\Domain\Model\Product\GroupedProduct)
midun mano
@Midun555
@cundd Kindly help me with this.. I have my own controllers. And I have all my video storage in https://3q.video/en/. They have their own APIs (https://sdn.3qsdn.com/api/doc) to render content in TYPO3 CMS (v9.5.14). How can I use your REST in my controllers.
Daniel Corn
@cundd
@Midun555 if i understand you correctly you want to achieve the opposite of what the REST extension offers: You want to consume a third-party REST API - is that correct? In this case the extension wouldn't do what you need
Jan Benes
@orcen
Hello, i have set up the api and it works fine if i create new Objects. The problem comes when i want to edit them, because im using record_types, and have multiple Classes that are used depending on this setting. On Update of the Model i get an error, that the Class isnt the one for what the endpoint ist registered.
Daniel Corn
@cundd
hello
Daniel Corn
@cundd
can you show me a bit more of the error message? Does it come from extbase?
8 replies
siebewebit
@siebewebit
Can anyone help me to set the configuration?
siebewebit
@siebewebit
Can I create pages with the rest api?
Daniel Corn
@cundd
You can achieve it in a very raw fashion using Virtual Objects
siebewebit
@siebewebit
So it is possible but not recommended?
Can you help me with the configuration? I did it like this https://rest.corn.rest/Configuration/Basic/ but I get the message "No site configuration found."
Daniel Corn
@cundd
Does your TYPO3 setup work on its own? Especially: Did you configure the site?
siebewebit
@siebewebit
The Typo3 setup works. I can see the "hello world!" In postman I do the following request: http://localhost:8888/rest
Daniel Corn
@cundd
Which TYPO3 version are you using?
siebewebit
@siebewebit
Schermafbeelding 2020-09-29 om 12.41.36.png
Daniel Corn
@cundd
TYPO3 10 is not supported yet
siebewebit
@siebewebit
So i need to install a lower version?
What is de success-response if I doe following request: http://localhost:8888/rest?
Daniel Corn
@cundd
TYPO3 9 is currently the latest supported version.
When it works, you will see a JSON with a greeting
siebewebit
@siebewebit
Ok, I will test version 9
Daniel Corn
@cundd
:+1: