GithubHelp home page GithubHelp logo

Comments (16)

catamphetamine avatar catamphetamine commented on May 29, 2024

Yes, you found a bug.
I released a new version, try it out.

from react-pages.

sorccu avatar sorccu commented on May 29, 2024

While your commit does fix this particular issue, it seems that it is currently not possible to pass query parameters to the destination at all. Fortunately I don't need them right now, but is there any way we could get that to work as well? Out of interest I tried require('url').format({ pathname: '/bar', query: { bar: null }, state: null }) earlier, but it produces ?bar= as the search string, whereas it was originally just ?bar without the =. So it wouldn't really be the original query.

from react-pages.

catamphetamine avatar catamphetamine commented on May 29, 2024

I don't understand the it seems that it is currently not possible to pass query parameters to the destination at all issue.
If you can explain it by an example I could take a look.

from react-pages.

sorccu avatar sorccu commented on May 29, 2024

The new changes result in this behavior:

% curl -vvv 'http://localhost:3002/foo?a&b=c'
*   Trying ::1...
* Connected to localhost (::1) port 3002 (#0)
> GET /foo?a&b=c HTTP/1.1
> Host: localhost:3002
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Location: /bar
< Content-Type: text/html; charset=utf-8
< Content-Length: 39
< Date: Mon, 10 Oct 2016 11:53:54 GMT
< Connection: keep-alive
<
* Connection #0 to host localhost left intact
Redirecting to <a href="/bar">/bar</a>.

All query parameters are lost in the redirect.

from react-pages.

sorccu avatar sorccu commented on May 29, 2024

Correction: they were lost even before your change. However, I feel like both issues should be fixed right now if possible. However, I took a quick look at redux-router's source code, and I'm not sure if they're giving us the original, unparsed query at all. So it might be difficult.

from react-pages.

sorccu avatar sorccu commented on May 29, 2024

The intention of the original code clearly is to pass the query parameters. However that is not happening right now at all as far as I can see.

from react-pages.

catamphetamine avatar catamphetamine commented on May 29, 2024

Well, it's working for me:

http://127.0.0.1:3000/example/database?a=b

<Redirect from='/example/database' to='/example/simple'/>

screen shot 2016-10-10 at 15 09 19

from react-pages.

sorccu avatar sorccu commented on May 29, 2024

I assume that's https://github.com/halt-hammerzeit/webapp. Doesn't it use webpack-isomorphic-tools for server side rendering?

from react-pages.

catamphetamine avatar catamphetamine commented on May 29, 2024

Yes, it does

from react-pages.

sorccu avatar sorccu commented on May 29, 2024

Then it probably doesn't suffer from the same issue as react-isomorphic-render?

I think https://github.com/halt-hammerzeit/webpack-react-redux-isomorphic-render-example would be more relevant as it uses react-isomorphic-render. You can see the same problem there:

% curl -vvv 'http://localhost:3000/example/database?a&b=c'
*   Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /example/database?a&b=c HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 302 Found
< location: /example/simpleundefined
< content-type: text/html; charset=utf-8
< content-length: 79
< date: Mon, 10 Oct 2016 12:25:37 GMT
< connection: close
<
* Closing connection 0
Redirecting to <a href="/example/simpleundefined">/example/simpleundefined</a>.

from react-pages.

catamphetamine avatar catamphetamine commented on May 29, 2024

webpack-isomorphic-tools and react-isomorphic-render have nothing in common

from react-pages.

catamphetamine avatar catamphetamine commented on May 29, 2024

webpack-isomorphic-tools doesn't know how to render anything

from react-pages.

sorccu avatar sorccu commented on May 29, 2024

Ok. Let's ignore webpack-isomorphic-tools since it's sidetracking the issue.

On a fresh clone of https://github.com/halt-hammerzeit/webpack-react-redux-isomorphic-render-example, you should be able to see the same redirect issue I posted earlier. Is there any chance we could get redirects with query parameters working there?

from react-pages.

catamphetamine avatar catamphetamine commented on May 29, 2024

Turned out webpack-react-redux-isomorphic-render-example had 4.x dependency of react-isomorphic-render set in package.json.
I upgraded it to 5.x.

The other bug seems to be in react-router:

@@@@@@@@@@@@@@ redirect_location { pathname: '/', query: { a: 'b' }, state: null }

It doesn't specify search parameter.
https://github.com/ReactTraining/react-router/blob/c3cd9675bd8a31368f87da74ac588981cbd6eae7/modules/createTransitionManager.js#L100

############# redirectInfo { pathname: '/', query: { a: 'b' }, state: null }

I filed a bug report in their repo
remix-run/react-router#4023

A workaround could be written using query-string's stringify()
https://www.npmjs.com/package/query-string

from react-pages.

catamphetamine avatar catamphetamine commented on May 29, 2024

Since they officially said that they aren't gonna fix this issue due to [email protected] branch support being dropped I implemented my own workaround.
So it's fixed in the new version.

from react-pages.

sorccu avatar sorccu commented on May 29, 2024

Thanks, looks great! There's one small issue remaining, I added a comment to your commit. Basically now redirects without any query parameters get ? always appended to them.

from react-pages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.