Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make env setup work in middleware #1000

Closed
iduuck opened this issue Dec 21, 2022 · 5 comments
Closed

feat: make env setup work in middleware #1000

iduuck opened this issue Dec 21, 2022 · 5 comments
Labels
🌟 enhancement New feature or request

Comments

@iduuck
Copy link
Contributor

iduuck commented Dec 21, 2022

Is your feature request related to a problem? Please describe.

I am currently facing a problem, when using the environment variable setup from t3 and I am opening this issue, since the other issue about environment variables not working (#999) was closed by the author.

Describe the solution you'd like to see

It would be necessary (for now – don't know, if this is being fixed, though) to also compose the server env vars, like we do for the client env vars.

Describe alternate solutions

non that i can think of.

Additional information

No response

@iduuck iduuck added the 🌟 enhancement New feature or request label Dec 21, 2022
@c-ehrlich
Copy link
Member

Could you explain more precisely what you are trying to do? Accessing env vars in middleware works just as it would anywhere else, see: c-ehrlich/mwenv@492bef2

@iduuck
Copy link
Contributor Author

iduuck commented Dec 23, 2022

Sorry, not speaking of trpc middleware, but of Next.js middleware.

@c-ehrlich
Copy link
Member

Just tried and can confirm that this currently doesn't work, the import makes Next middleware blow up. Accessing the environment variables in a non-typesafe way (ie process.env.SERVERVAR does work, but obviously isn't ideal.

What would we need to do to get it to work, and are there any downsides?

@iduuck
Copy link
Contributor Author

iduuck commented Dec 27, 2022

I think the only way to work around this, is to define the server env vars the same way, as we do with the client env vars (explicitly building our env object before verifying).

@iduuck
Copy link
Contributor Author

iduuck commented Jan 8, 2023

fixed by #1021

@iduuck iduuck closed this as completed Jan 8, 2023
@iduuck iduuck mentioned this issue Jan 21, 2023
3 tasks
devvianto605 pushed a commit to devvianto605/create-devviantex-nextjs-app-deprecated that referenced this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants